Do not send invite email when invite button is pressed
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
/* global angular:false */
|
||||
/* global Clipboard:false */
|
||||
/* global asyncForEach:false */
|
||||
/* global asyncSeries:false */
|
||||
|
||||
angular.module('Application').controller('UsersController', ['$scope', '$location', '$timeout', 'Client', function ($scope, $location, $timeout, Client) {
|
||||
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
|
||||
@@ -109,7 +110,6 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
username: $scope.useradd.username || null,
|
||||
email: $scope.useradd.email,
|
||||
displayName: $scope.useradd.displayName,
|
||||
sendInvite: $scope.useradd.sendInvite,
|
||||
admin: $scope.useradd.admin
|
||||
};
|
||||
|
||||
@@ -151,11 +151,16 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
}
|
||||
|
||||
var groupIds = $scope.useradd.selectedGroups.map(function (g) { return g.id; });
|
||||
var NOOP = function (next) { next(); };
|
||||
|
||||
Client.setGroups(newUserInfo.id, groupIds, function (error) {
|
||||
asyncSeries([
|
||||
Client.setGroups.bind(Client, newUserInfo.id, groupIds),
|
||||
$scope.useradd.sendInvite ? Client.createInvite.bind(Client, newUserInfo.id) : NOOP,
|
||||
$scope.useradd.sendInvite ? Client.sendInvite.bind(Client, newUserInfo.id) : NOOP
|
||||
], function (error) {
|
||||
$scope.useradd.busy = false;
|
||||
|
||||
if (error) return console.error('Unable to update groups for user:', error);
|
||||
if (error) return console.error(error);
|
||||
|
||||
refresh();
|
||||
|
||||
@@ -347,11 +352,6 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
}
|
||||
};
|
||||
|
||||
$scope.inviteSent = {
|
||||
email: '',
|
||||
setupLink: ''
|
||||
};
|
||||
|
||||
$scope.groupRemove = {
|
||||
busy: false,
|
||||
error: {},
|
||||
@@ -405,18 +405,34 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
return user.username === Client.getUserInfo().username;
|
||||
};
|
||||
|
||||
$scope.sendInvite = function (user) {
|
||||
$scope.inviteSent.email = user.fallbackEmail;
|
||||
$scope.inviteSent.setupLink = '';
|
||||
$scope.invitation = {
|
||||
busy: false,
|
||||
setupLink: '',
|
||||
user: null,
|
||||
|
||||
Client.sendInvite(user, function (error, resetToken) {
|
||||
if (error) return console.error(error);
|
||||
show: function (user) {
|
||||
$scope.invitation.user = user;
|
||||
$scope.invitation.setupLink = '';
|
||||
$scope.invitation.busy = false;
|
||||
|
||||
// Client.notify('', 'Invitation was successfully sent to ' + user.email + '.', false, 'success');
|
||||
Client.createInvite(user.id, function (error, resetToken) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
$scope.inviteSent.setupLink = location.origin + '/api/v1/session/account/setup.html?reset_token=' + resetToken + '&email=' + encodeURIComponent(user.email);
|
||||
$('#inviteSentModal').modal('show');
|
||||
});
|
||||
$scope.invitation.setupLink = location.origin + '/api/v1/session/account/setup.html?reset_token=' + resetToken + '&email=' + encodeURIComponent($scope.invitation.user.email);
|
||||
|
||||
$('#invitationModal').modal('show');
|
||||
});
|
||||
},
|
||||
|
||||
email: function () {
|
||||
$scope.invitation.busy = true;
|
||||
|
||||
Client.sendInvite($scope.invitation.user.id, function (error) {
|
||||
$scope.invitation.busy = false;
|
||||
if (error) return console.error(error);
|
||||
$('#invitationModal').modal('hide');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.copyToClipboard = function (/*value*/) {
|
||||
|
||||
Reference in New Issue
Block a user