Closes #164: admin can send a password reset email to users

This commit is contained in:
Benjamin Gamard 2018-01-07 19:56:11 +01:00
parent b2d9684738
commit 7fc50f2629
3 changed files with 30 additions and 9 deletions

View File

@ -64,7 +64,7 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog,
]; ];
$dialog.messageBox(title, msg, btns, function (result) { $dialog.messageBox(title, msg, btns, function (result) {
if (result == 'ok') { if (result === 'ok') {
Restangular.one('user', $stateParams.username).remove().then(function () { Restangular.one('user', $stateParams.username).remove().then(function () {
$scope.loadUsers(); $scope.loadUsers();
$state.go('settings.user'); $state.go('settings.user');
@ -75,4 +75,14 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog,
}); });
}; };
$scope.passwordReset = function () {
Restangular.one('user').post('password_lost', {
username: $stateParams.username
}).then(function () {
var title = $translate.instant('settings.user.edit.password_lost_sent_title');
var msg = $translate.instant('settings.user.edit.password_lost_sent_message', { username: $stateParams.username });
var btns = [{result: 'ok', label: $translate.instant('ok'), cssClass: 'btn-primary'}];
$dialog.messageBox(title, msg, btns);
});
};
}); });

View File

@ -249,7 +249,10 @@
"storage_quota_placeholder": "Storage quota (in MB)", "storage_quota_placeholder": "Storage quota (in MB)",
"password": "Password", "password": "Password",
"password_confirm": "Password (confirm)", "password_confirm": "Password (confirm)",
"disabled": "Disabled user" "disabled": "Disabled user",
"password_reset_btn": "Send a password reset email to this user",
"password_lost_sent_title": "Password reset email sent",
"password_lost_sent_message": "A password reset email has been sent to <strong>{{ username }}</strong> for a password reset"
} }
}, },
"security": { "security": {

View File

@ -109,5 +109,13 @@
</button> </button>
</div> </div>
</div> </div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-warning" ng-click="passwordReset()" ng-show="user.username != 'guest'">
<span class="glyphicon glyphicon-repeat"></span> {{ 'settings.user.edit.password_reset_btn' | translate }}
</button>
</div>
</div>
</form> </form>
</div> </div>