Allow superusers to disable user accounts

This commit is contained in:
Joseph Schorr 2015-05-11 17:13:42 -04:00
parent 442cbed087
commit dc5af7496c
19 changed files with 291 additions and 37 deletions

View file

@ -0,0 +1,25 @@
.super-user .user-row {
border-bottom: 0px;
}
.super-user .user-row td {
vertical-align: middle;
}
.super-user .user-row .user-class {
text-transform: uppercase;
}
.super-user .user-row .labels {
float: right;
white-space: nowrap;
}
.super-user .user-row .labels .label {
text-transform: uppercase;
margin-right: 10px;
}
.super-user .user-row.disabled .avatar {
-webkit-filter: grayscale(100%);
}

View file

@ -3928,28 +3928,6 @@ pre.command:before {
padding: 6px;
}
.user-row {
border-bottom: 0px;
}
.user-row td {
vertical-align: middle;
}
.user-row .user-class {
text-transform: uppercase;
}
.user-row .labels {
float: right;
white-space: nowrap;
}
.user-row .labels .label {
text-transform: uppercase;
margin-right: 10px;
}
.form-change input {
margin-top: 12px;
margin-bottom: 12px;

View file

@ -1,12 +1,12 @@
<div class="signin-form-element">
<span class="quay-spinner" ng-show="signingIn"></span>
<div class="signin-form-element" style="position: relative">
<span class="cor-loader" ng-show="signingIn"></span>
<form class="form-signin" ng-submit="signin();" ng-show="!signingIn">
<input type="text" class="form-control input-lg" name="username"
placeholder="Username or E-mail Address" ng-model="user.username" autofocus>
<input type="password" class="form-control input-lg" name="password"
placeholder="Password" ng-model="user.password">
<div class="alert alert-warning" ng-show="tryAgainSoon > 0">
<div class="co-alert co-alert-warning" ng-show="tryAgainSoon > 0">
Too many attempts have been made to login. Please try again in {{ tryAgainSoon }} second<span ng-if="tryAgainSoon != 1">s</span>.
</div>
@ -23,8 +23,10 @@
</span>
</form>
<div class="alert alert-danger" ng-show="invalidCredentials">Invalid username or password.</div>
<div class="alert alert-danger" ng-show="needsEmailVerification">
<div class="co-alert co-alert-danger" ng-show="invalidCredentials">
{{ invalidCredentialsMessage || 'Invalid username or password.' }}
</div>
<div class="co-alert co-alert-danger" ng-show="needsEmailVerification">
You must verify your email address before you can sign in.
</div>
</div>

View file

@ -53,6 +53,7 @@ angular.module('quay').directive('signinForm', function () {
$scope.signingIn = false;
$scope.needsEmailVerification = false;
$scope.invalidCredentials = false;
$scope.invalidCredentialsMessage = null;
if ($scope.signedIn != null) {
$scope.signedIn();
@ -77,6 +78,7 @@ angular.module('quay').directive('signinForm', function () {
if (result.status == 429 /* try again later */) {
$scope.needsEmailVerification = false;
$scope.invalidCredentials = false;
$scope.invalidCredentialsMessage = null;
$scope.cancelInterval();
@ -87,9 +89,12 @@ angular.module('quay').directive('signinForm', function () {
$scope.cancelInterval();
}
}, 1000, $scope.tryAgainSoon);
} else if (result.status == 400) {
bootbox.alert(ApiService.getErrorMessage(result));
} else {
$scope.needsEmailVerification = result.data.needsEmailVerification;
$scope.invalidCredentials = result.data.invalidCredentials;
$scope.invalidCredentialsMessage = result.data.message;
}
});
};

View file

@ -232,6 +232,32 @@
});
};
$scope.askDisableUser = function(user) {
var message = 'Are you sure you want to disable this user? ' +
'They will be unable to login, pull or push.'
if (!user.enabled) {
message = 'Are you sure you want to reenable this user? ' +
'They will be able to login, pull or push.'
}
bootbox.confirm(message, function(resp) {
if (resp) {
var params = {
'username': user.username
};
var data = {
'enabled': !user.enabled
};
ApiService.changeInstallUser(data, params).then(function(resp) {
$scope.loadUsersInternal();
});
}
});
};
$scope.changeUserPassword = function(user) {
$('#changePasswordModal').modal('hide');

View file

@ -156,7 +156,8 @@
</thead>
<tr ng-repeat="current_user in (users | filter:search | orderBy:'username')"
class="user-row">
class="user-row"
ng-class="current_user.enabled ? 'enabled': 'disabled'">
<td>
<span class="avatar" data="current_user.avatar" size="24"></span>
</td>
@ -165,6 +166,8 @@
<span class="label label-success" ng-if="user.username == current_user.username">You</span>
<span class="label label-primary"
ng-if="current_user.super_user">Superuser</span>
<span class="label label-default"
ng-if="!current_user.enabled">Disabled</span>
</span>
{{ current_user.username }}
</td>
@ -187,6 +190,9 @@
<span class="cor-option" option-click="showDeleteUser(current_user)">
<i class="fa fa-times"></i> Delete User
</span>
<span class="cor-option" option-click="askDisableUser(current_user)">
<i class="fa" ng-class="current_user.enabled ? 'fa-circle-o' : 'fa-check-circle-o'"></i> <span ng-if="current_user.enabled">Disable</span> <span ng-if="!current_user.enabled">Enable</span> User
</span>
</span>
</td>
</tr>