Skip to content
Snippets Groups Projects
Commit 98fd5bd2 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Only member can send invitation to certify - fix #561

parent 2f58dce5
No related branches found
No related tags found
No related merge requests found
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
"REMOVE_INVITATION_FAILED": "Error while deleting the invitation", "REMOVE_INVITATION_FAILED": "Error while deleting the invitation",
"REMOVE_ALL_INVITATIONS_FAILED": "Error while deleting invitations", "REMOVE_ALL_INVITATIONS_FAILED": "Error while deleting invitations",
"SEND_INVITATION_FAILED": "Error while sending invitation", "SEND_INVITATION_FAILED": "Error while sending invitation",
"BAD_INVITATION_FORMAT": "<span class=\"assertive\"><i class=\"ion-close-circled\"></i> Invitation unreadable (format unknown)</span> - sent by <a href=\"#/app/wot/{{pubkey}}/{{::uid}}\">{{::name||uid||pubkey}}</a>" "BAD_INVITATION_FORMAT": "<span class=\"assertive\"><i class=\"ion-close-circled\"></i> Invitation unreadable (format unknown)</span> - sent by <a ui-sref=\"app.wot_identity({pubkey: '{{::pubkey}}', uid: '{{::uid}}' })\">{{::name||uid}}</a>"
} }
}, },
"COMMENTS": { "COMMENTS": {
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
"REMOVE_INVITATION_FAILED": "Error while deleting the invitation", "REMOVE_INVITATION_FAILED": "Error while deleting the invitation",
"REMOVE_ALL_INVITATIONS_FAILED": "Error while deleting invitations", "REMOVE_ALL_INVITATIONS_FAILED": "Error while deleting invitations",
"SEND_INVITATION_FAILED": "Error while sending invitation", "SEND_INVITATION_FAILED": "Error while sending invitation",
"BAD_INVITATION_FORMAT": "<span class=\"assertive\"><i class=\"ion-close-circled\"></i> Invitation unreadable (format unknown)</span> - sent by <a href=\"#/app/wot/{{pubkey}}/{{::uid}}\">{{::name||uid||pubkey}}</a>" "BAD_INVITATION_FORMAT": "<span class=\"assertive\"><i class=\"ion-close-circled\"></i> Invitation unreadable (format unknown)</span> - sent by <a ui-sref=\"app.wot_identity({pubkey: '{{::pubkey}}', uid: '{{::uid}}' })\">{{::name||uid}}</a>"
} }
}, },
"COMMENTS": { "COMMENTS": {
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
"REMOVE_INVITATION_FAILED": "Fracaso durante la supresión de la invitación", "REMOVE_INVITATION_FAILED": "Fracaso durante la supresión de la invitación",
"REMOVE_ALL_INVITATIONS_FAILED": "Fracaso durante la supresión de las invitaciónes", "REMOVE_ALL_INVITATIONS_FAILED": "Fracaso durante la supresión de las invitaciónes",
"SEND_INVITATION_FAILED": "Fracaso durante el envío de la invitación", "SEND_INVITATION_FAILED": "Fracaso durante el envío de la invitación",
"BAD_INVITATION_FORMAT": "<span class=\"assertive\"><i class=\"ion-close-circled\"></i> Invitación ilegible (formato desconocido)</span> - mandada por <a href=\"#/app/wot/{{pubkey}}/{{::uid}}\">{{::name||uid}}</a>" "BAD_INVITATION_FORMAT": "<span class=\"assertive\"><i class=\"ion-close-circled\"></i> Invitación ilegible (formato desconocido)</span> - mandada por <a ui-sref=\"app.wot_identity({pubkey: '{{::pubkey}}', uid: '{{::uid}}' })\">{{::name||uid}}</a>"
} }
}, },
"COMMENTS": { "COMMENTS": {
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
"REMOVE_INVITATION_FAILED": "Erreur lors de la suppression de l'invitation", "REMOVE_INVITATION_FAILED": "Erreur lors de la suppression de l'invitation",
"REMOVE_ALL_INVITATIONS_FAILED": "Erreur lors de la suppression des invitations", "REMOVE_ALL_INVITATIONS_FAILED": "Erreur lors de la suppression des invitations",
"SEND_INVITATION_FAILED": "Erreur lors de l'envoi de l'invitation", "SEND_INVITATION_FAILED": "Erreur lors de l'envoi de l'invitation",
"BAD_INVITATION_FORMAT": "<span class=\"assertive\"><i class=\"ion-close-circled\"></i> Invitation illisible (format inconnu)</span> - envoyée par <a href=\"#/app/wot/{{pubkey}}/{{::uid}}\">{{::name||uid}}</a>" "BAD_INVITATION_FORMAT": "<span class=\"assertive\"><i class=\"ion-close-circled\"></i> Invitation illisible (format inconnu)</span> - envoyée par <a ui-sref=\"app.wot_identity({pubkey: '{{::pubkey}}', uid: '{{::uid}}' })\">{{::name||uid}}</a>"
} }
}, },
"COMMENTS": { "COMMENTS": {
......
...@@ -125,8 +125,6 @@ function ESMenuExtendController($scope, $state, PluginService, esSettings, UIUti ...@@ -125,8 +125,6 @@ function ESMenuExtendController($scope, $state, PluginService, esSettings, UIUti
popover.scope.closePopover(); popover.scope.closePopover();
}); });
} }
})
.then(function() {
}); });
}; };
......
...@@ -194,6 +194,11 @@ function InvitationsController($scope, $q, $ionicPopover, $state, $timeout, UIUt ...@@ -194,6 +194,11 @@ function InvitationsController($scope, $q, $ionicPopover, $state, $timeout, UIUt
$scope.showNewInvitationModal = function() { $scope.showNewInvitationModal = function() {
$scope.hideActionsPopover(); $scope.hideActionsPopover();
// Not allow for non-member - issue #561
if (!csWallet.data.isMember) {
return UIUtils.alert.error('ERROR.ONLY_MEMBER_CAN_EXECUTE_THIS_ACTION');
}
esModals.showNewInvitation({}); esModals.showNewInvitation({});
}; };
......
...@@ -61,7 +61,7 @@ angular.module('cesium.es.message.controllers', ['cesium.es.services']) ...@@ -61,7 +61,7 @@ angular.module('cesium.es.message.controllers', ['cesium.es.services'])
; ;
function ESMessageListController($scope, $state, $translate, $ionicHistory, $ionicPopover, $timeout, function ESMessageListController($scope, $state, $translate, $ionicHistory, $ionicPopover, $timeout,
esModals, UIUtils, esMessage) { csWallet, esModals, UIUtils, esMessage) {
'ngInject'; 'ngInject';
$scope.loading = true; $scope.loading = true;
...@@ -267,7 +267,7 @@ function ESMessageListController($scope, $state, $translate, $ionicHistory, $ion ...@@ -267,7 +267,7 @@ function ESMessageListController($scope, $state, $translate, $ionicHistory, $ion
// Watch received message // Watch received message
$scope.onNewInboxMessage = function(notification) { $scope.onNewInboxMessage = function(notification) {
if ($scope.type != 'inbox') return; if ($scope.type != 'inbox' || !$scope.entered) return;
// Add message sent to list // Add message sent to list
$scope.loading = true; $scope.loading = true;
// Load the the message // Load the the message
...@@ -283,6 +283,15 @@ function ESMessageListController($scope, $state, $translate, $ionicHistory, $ion ...@@ -283,6 +283,15 @@ function ESMessageListController($scope, $state, $translate, $ionicHistory, $ion
}; };
esMessage.api.data.on.new($scope, $scope.onNewInboxMessage); esMessage.api.data.on.new($scope, $scope.onNewInboxMessage);
// Watch unauth
$scope.onUnauth = function() {
// Reset all data
$scope.messages = undefined;
$scope.loading = false;
$scope.entered = false;
};
csWallet.api.data.on.unauth($scope, $scope.onUnauth);
// for DEV only // for DEV only
/*$timeout(function() { /*$timeout(function() {
$scope.showNewMessageModal(); $scope.showNewMessageModal();
......
...@@ -63,7 +63,6 @@ function Invitation(json) { ...@@ -63,7 +63,6 @@ function Invitation(json) {
that.uid = identity.uid; that.uid = identity.uid;
} }
} }
} }
...@@ -94,6 +94,15 @@ angular.module('cesium.es.invitation.services', ['cesium.platform', ...@@ -94,6 +94,15 @@ angular.module('cesium.es.invitation.services', ['cesium.platform',
function onNewInvitationEvent(event) { function onNewInvitationEvent(event) {
console.debug("[ES] [invitation] detected new invitation (from notification service)"); console.debug("[ES] [invitation] detected new invitation (from notification service)");
// If user not auth: simply increment counter
if (!csWallet.isAuth()) {
$rootScope.$apply(function() {
csWallet.data.invitations = csWallet.data.invitations || {};
csWallet.data.invitations.unreadCount++;
});
return;
}
getInvitationById(event.reference.id, event.reference.type) getInvitationById(event.reference.id, event.reference.type)
.then(function(invitation){ .then(function(invitation){
csWallet.data.invitations = csWallet.data.invitations || {}; csWallet.data.invitations = csWallet.data.invitations || {};
......
...@@ -236,6 +236,10 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt ...@@ -236,6 +236,10 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt
var boxKeypair = res[0]; var boxKeypair = res[0];
var nonce = res[1]; var nonce = res[1];
// Make sure user has not disconnect
// This can occur, when auth + disabling ES plugin in settings
if (!boxKeypair.boxPk || !boxKeypair.boxSk) return;
var record = { var record = {
issuer: csWallet.data.pubkey, issuer: csWallet.data.pubkey,
nonce: CryptoUtils.util.encode_base58(nonce), nonce: CryptoUtils.util.encode_base58(nonce),
...@@ -243,7 +247,6 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt ...@@ -243,7 +247,6 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt
}; };
//console.debug("Will store settings remotely: ", filteredData); //console.debug("Will store settings remotely: ", filteredData);
var json = JSON.stringify(filteredData); var json = JSON.stringify(filteredData);
return CryptoUtils.box.pack(json, nonce, boxKeypair.boxPk, boxKeypair.boxSk) return CryptoUtils.box.pack(json, nonce, boxKeypair.boxPk, boxKeypair.boxSk)
...@@ -253,9 +256,13 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt ...@@ -253,9 +256,13 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt
return !data.time ? return !data.time ?
that.add(record) : that.add(record) :
that.update(record, {id: record.issuer}); that.update(record, {id: record.issuer});
});
}) })
.then(function() { .then(function() {
return true;
});
})
.then(function(saved) {
if (!saved) return;
// Update settings version, then store (on local store only) // Update settings version, then store (on local store only)
csSettings.data.time = time; csSettings.data.time = time;
previousRemoteData = filteredData; previousRemoteData = filteredData;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment