Make resolution of join requests only available through the app and by the owner of the group (in cloud code as well).

This commit is contained in:
Georgi Prodanov 2017-03-15 16:13:28 +02:00
Родитель a2fd853935
Коммит 448bcdedee
5 изменённых файлов: 24 добавлений и 8 удалений

Просмотреть файл

@ -1,5 +1,5 @@
@import '~/css/core.light.css';
@import '~/css/core.light.css';
@import 'nativescript-theme-core/css/core.light.css';
@import url('./platform.css');
@ -163,3 +163,8 @@ ActivityIndicator {
margin-right: 10;
font-size: 20;
}
.ios-back-btn .icon {
width: 20;
height: 20;
}

Просмотреть файл

@ -4,8 +4,8 @@
<ActionBarExtension>
<NavigationButton *ngIf="isAndroid" icon="res://icon_back" (tap)="onBack()"></NavigationButton>
<ActionItem *ngIf="!isAndroid && (membershipChanged || !canGoBack())" ios.systemIcon="1" ios.position="left" (tap)="onBack()">
<StackLayout orientation="horizontal">
<Image src="res://icon_back"></Image>
<StackLayout class="ios-back-btn" orientation="horizontal">
<Image class="icon" src="res://icon_back"></Image>
<label text="Groups"></label>
</StackLayout>
</ActionItem>

Просмотреть файл

@ -5,8 +5,8 @@
<ActionBarExtension>
<NavigationButton *ngIf="isAndroid" icon="res://icon_back" (tap)="onBack()"></NavigationButton>
<ActionItem *ngIf="!isAndroid && hasApprovedSome" ios.systemIcon="1" ios.position="left" (tap)="onBack()">
<StackLayout orientation="horizontal">
<Image src="res://icon_back"></Image>
<StackLayout class="ios-back-btn" orientation="horizontal">
<Image class="icon" src="res://icon_back"></Image>
<label text="Groups"></label>
</StackLayout>
</ActionItem>

Просмотреть файл

@ -96,6 +96,9 @@ export function startsWith (str: string, substr: string) {
}
export function prettifySystemErrors (rawErrorMsg: string) {
if (!rawErrorMsg) {
return rawErrorMsg;
}
let errorsToPrettify = Object.keys(constants.systemErrorMsgs);
let result: string = rawErrorMsg;
let keyIndex = findIndex(errorsToPrettify, errMsg => startsWith(rawErrorMsg, errMsg));

Просмотреть файл

@ -20,16 +20,24 @@ Everlive.CloudFunction.onRequest(function(request, response, done) {
var requestsDb = el.data('GroupJoinRequests');
var groupsDb = el.data('Groups');
var req, group;
requestsDb.getById(reqId)
.then(function(resp) {
var req = resp.result;
req = resp.result;
if (req.Resolved) {
return Promise.reject({ message: 'This request has already been resolved' });
}
return groupsDb.getById(req.GroupId);
})
.then(function(resp) {
group = resp.result;
if (request.principal.type === 'user' && group.Owner !== request.principal.id) {
return Promise.reject({ message: 'You are not authorized for this operation' });
}
req.Approved = approved;
req.Resolved = true;
return requestsDb.updateSingle(req);
})
.then(function(resp) {
var updatedCount = resp.result;