mirror of
https://github.com/usememos/memos.git
synced 2025-01-09 13:50:24 +08:00
feat: list access tokens by admin (#2434)
* Allow admin user list access_tokens of anyone * fix undefined variable * Update api/v2/user_service.go --------- Co-authored-by: boojack <stevenlgtm@gmail.com>
This commit is contained in:
parent
79bbe4b82a
commit
496cde87b2
1 changed files with 6 additions and 1 deletions
|
@ -156,7 +156,12 @@ func (s *UserService) ListUserAccessTokens(ctx context.Context, request *apiv2pb
|
|||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err)
|
||||
}
|
||||
if user == nil || user.Username != request.Username {
|
||||
if user == nil {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
|
||||
// Normal users can only list their access tokens.
|
||||
if user.Role == store.RoleUser && user.Username != request.Username {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue