mirror of
https://github.com/sismics/docs.git
synced 2024-12-25 20:53:48 +01:00
Closes #164: admin can send a password reset email to users
This commit is contained in:
parent
b2d9684738
commit
7fc50f2629
@ -7,7 +7,7 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog,
|
||||
/**
|
||||
* Returns true if in edit mode (false in add mode).
|
||||
*/
|
||||
$scope.isEdit = function() {
|
||||
$scope.isEdit = function () {
|
||||
return $stateParams.username;
|
||||
};
|
||||
|
||||
@ -15,7 +15,7 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog,
|
||||
* In edit mode, load the current user.
|
||||
*/
|
||||
if ($scope.isEdit()) {
|
||||
Restangular.one('user', $stateParams.username).get().then(function(data) {
|
||||
Restangular.one('user', $stateParams.username).get().then(function (data) {
|
||||
data.storage_quota /= 1000000;
|
||||
$scope.user = data;
|
||||
});
|
||||
@ -24,7 +24,7 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog,
|
||||
/**
|
||||
* Update the current user.
|
||||
*/
|
||||
$scope.edit = function() {
|
||||
$scope.edit = function () {
|
||||
var promise = null;
|
||||
var user = angular.copy($scope.user);
|
||||
user.storage_quota *= 1000000;
|
||||
@ -39,7 +39,7 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog,
|
||||
.put(user);
|
||||
}
|
||||
|
||||
promise.then(function() {
|
||||
promise.then(function () {
|
||||
$scope.loadUsers();
|
||||
$state.go('settings.user');
|
||||
}, function (e) {
|
||||
@ -55,7 +55,7 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog,
|
||||
/**
|
||||
* Delete the current user.
|
||||
*/
|
||||
$scope.remove = function() {
|
||||
$scope.remove = function () {
|
||||
var title = $translate.instant('settings.user.edit.delete_user_title');
|
||||
var msg = $translate.instant('settings.user.edit.delete_user_message');
|
||||
var btns = [
|
||||
@ -63,9 +63,9 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog,
|
||||
{ result:'ok', label: $translate.instant('ok'), cssClass: 'btn-primary' }
|
||||
];
|
||||
|
||||
$dialog.messageBox(title, msg, btns, function(result) {
|
||||
if (result == 'ok') {
|
||||
Restangular.one('user', $stateParams.username).remove().then(function() {
|
||||
$dialog.messageBox(title, msg, btns, function (result) {
|
||||
if (result === 'ok') {
|
||||
Restangular.one('user', $stateParams.username).remove().then(function () {
|
||||
$scope.loadUsers();
|
||||
$state.go('settings.user');
|
||||
}, function() {
|
||||
@ -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);
|
||||
});
|
||||
};
|
||||
});
|
@ -249,7 +249,10 @@
|
||||
"storage_quota_placeholder": "Storage quota (in MB)",
|
||||
"password": "Password",
|
||||
"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": {
|
||||
|
@ -109,5 +109,13 @@
|
||||
</button>
|
||||
</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>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user