mirror of
https://github.com/gogs/gogs.git
synced 2025-12-27 10:40:01 +01:00
* api/v1: don't allow multiple tokens with same name Fail with 422 Unprocessable Entity if the token name already exist ref: https://github.com/gogs/gogs/issues/5587 * Move new token error type to models/errors/token * Remove "useless" ListAccessTokensByName function * Add an i18n entry for token_name_exists
17 lines
328 B
Go
17 lines
328 B
Go
package errors
|
|
|
|
import "fmt"
|
|
|
|
type AccessTokenNameAlreadyExist struct {
|
|
Name string
|
|
}
|
|
|
|
func IsAccessTokenNameAlreadyExist(err error) bool {
|
|
_, ok := err.(AccessTokenNameAlreadyExist)
|
|
return ok
|
|
}
|
|
|
|
func (err AccessTokenNameAlreadyExist) Error() string {
|
|
return fmt.Sprintf("access token already exist [name: %s]", err.Name)
|
|
}
|