configstore: create token only if it doesn't exists
This commit is contained in:
parent
c4310be7de
commit
200aef20b9
@ -660,6 +660,11 @@ func (s *CommandHandler) CreateUserToken(ctx context.Context, userName, tokenNam
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if user.Tokens != nil {
|
||||
if _, ok := user.Tokens[tokenName]; ok {
|
||||
return "", util.NewErrBadRequest(errors.Errorf("token %q for user %q already exists", tokenName, userName))
|
||||
}
|
||||
}
|
||||
|
||||
if user.Tokens == nil {
|
||||
user.Tokens = make(map[string]string)
|
||||
|
Loading…
Reference in New Issue
Block a user