mirror of
https://github.com/go-gitea/gitea.git
synced 2024-05-11 05:55:29 +00:00
Disable add key button if SSH is disabled (#2873)
This commit is contained in:
@ -37,6 +37,20 @@ func (err ErrNamePatternNotAllowed) Error() string {
|
||||
return fmt.Sprintf("name pattern is not allowed [pattern: %s]", err.Pattern)
|
||||
}
|
||||
|
||||
// ErrSSHDisabled represents an "SSH disabled" error.
|
||||
type ErrSSHDisabled struct {
|
||||
}
|
||||
|
||||
// IsErrSSHDisabled checks if an error is a ErrSSHDisabled.
|
||||
func IsErrSSHDisabled(err error) bool {
|
||||
_, ok := err.(ErrSSHDisabled)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (err ErrSSHDisabled) Error() string {
|
||||
return "SSH is disabled"
|
||||
}
|
||||
|
||||
// ____ ___
|
||||
// | | \______ ___________
|
||||
// | | / ___// __ \_ __ \
|
||||
|
@ -260,7 +260,7 @@ func SSHNativeParsePublicKey(keyLine string) (string, int, error) {
|
||||
// It returns the actual public key line on success.
|
||||
func CheckPublicKeyString(content string) (_ string, err error) {
|
||||
if setting.SSH.Disabled {
|
||||
return "", errors.New("SSH is disabled")
|
||||
return "", ErrSSHDisabled{}
|
||||
}
|
||||
|
||||
content, err = parseKeyString(content)
|
||||
|
Reference in New Issue
Block a user