mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-15 14:38:03 +02:00
Add user ban/activate feature
Add admin endpoints to ban and activate users, block banned users from all auth flows (OAuth, token login, bearer auth), and invalidate existing sessions on next request. Includes frontend translation and user detail page ban/activate buttons.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
"not_authorized": "You do not have permission to perform this action.",
|
||||
"unable_to_connect_user": "Unable to connect your account. Please try again later.",
|
||||
"user_not_found": "The requested user could not be found.",
|
||||
"user_banned": "Your account has been banned. Contact the admin for more information.",
|
||||
"repo_access_limited": "GitHub blocked access because the repository's organization restricts third-party OAuth apps. Ask an org owner to approve Anonymous GitHub under Settings → Third-party Access → OAuth app policy, or anonymize a personal fork instead.",
|
||||
"repo_not_found": "The repository was not found on GitHub. Check the URL and spelling, make sure you are signed in to the account that can see it, and confirm the repo isn't hidden under an org that restricts third-party app access.",
|
||||
"repo_empty": "The selected branch has no commits on GitHub. Push at least one commit, or pick a different branch, then retry.",
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
</span>
|
||||
<span class="type-badge type-repo" ng-if="userInfo.isAdmin">Admin</span>
|
||||
</h1>
|
||||
<div class="user-actions" style="margin-top: 4px;">
|
||||
<button class="btn btn-sm text-danger" ng-if="userInfo.status !== 'banned'" ng-click="banUser()"><i class="fas fa-ban"></i> Ban</button>
|
||||
<button class="btn btn-sm" ng-if="userInfo.status === 'banned' || userInfo.status === 'removed'" ng-click="activateUser()"><i class="fas fa-check-circle"></i> Activate</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -519,6 +519,18 @@ angular
|
||||
getUser($routeParams.username);
|
||||
getUserRepositories($routeParams.username);
|
||||
|
||||
$scope.banUser = () => {
|
||||
if (!confirm(`Ban user ${$routeParams.username}?`)) return;
|
||||
$http
|
||||
.post(`/api/admin/users/${$routeParams.username}/ban`)
|
||||
.then(() => getUser($routeParams.username), (err) => console.error(err));
|
||||
};
|
||||
$scope.activateUser = () => {
|
||||
$http
|
||||
.post(`/api/admin/users/${$routeParams.username}/activate`)
|
||||
.then(() => getUser($routeParams.username), (err) => console.error(err));
|
||||
};
|
||||
|
||||
$scope.tokens = [];
|
||||
$scope.tokenForm = { name: "", plaintext: null };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user