Skip to content

Commit

Permalink
#1303 Add MFA flags and actions in user management section
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed May 2, 2020
1 parent a45ff6e commit 15c80dd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
26 changes: 26 additions & 0 deletions frontend/app/scripts/components/organisation/OrgUserListCmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,32 @@
});
};

self.resetMfa = function(user) {
var modalInstance = ModalSrv.confirm(
'Reset MFA',
'Are you sure you want to reset MFA settings for this user?', {
okText: 'Yes, reset it',
flavor: 'danger'
}
);

modalInstance.result
.then(function() {
UserSrv.resetMfa(user._id);
})
.then(function() {
self.onReload();
NotificationSrv.success(
'MFA configuration of user ' + user.login + ' has been successfully disabled.'
);
})
.catch(function(err) {
if (!_.isString(err)) {
NotificationSrv.error('OrgUserCtrl', err.data, err.status);
}
});
};

self.createKey = function(user) {
var modalInstance = ModalSrv.confirm(
'Create API key',
Expand Down
6 changes: 4 additions & 2 deletions frontend/app/scripts/services/api/UserSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@
});
};

this.resetMfa = function() {
return $http.post('./api/v1/auth/totp/unset');
this.resetMfa = function(user) {
var url = './api/v1/auth/totp/unset';

return $http.post(user ? (url+'/'+ user) : url );
};

this.list = function(organisation, query) {
Expand Down
11 changes: 10 additions & 1 deletion frontend/app/views/components/org/user.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<th></th>
<th>Password</th>
<th>API Key</th>
<th style="width: 200px"></th>
<th class="text-center" style="width: 100px">MFA</th>
<th style="width: 180px"></th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -83,6 +84,14 @@ <h4 class="media-heading">
</div>
</span>
</td>
<td class="text-center">
<span ng-if="!user.hasMFA">
No
</span>
<span ng-if="user.hasMFA">
<button type="button" class="btn btn-danger btn-sm" ng-click="$ctrl.resetMfa(user)">Reset</button>
</span>
</td>
<td>
<span class="clickable mr-xxxs text-primary" ng-click="$ctrl.editUser(user)">
<i class="fa fa-edit"></i>Edit</span>
Expand Down

0 comments on commit 15c80dd

Please sign in to comment.