1
0

Disable the user account after 10 failed password attempts

This commit is contained in:
kolaente
2021-07-29 18:45:22 +02:00
parent 3572ac4b82
commit 5cfc9bf2f9
7 changed files with 122 additions and 10 deletions

View File

@ -425,3 +425,30 @@ func (err *ErrNoOpenIDEmailProvided) HTTPError() web.HTTPError {
Message: "No email address available. Please make sure the openid provider publicly provides an email address for your account.",
}
}
// ErrAccountDisabled represents a "AccountDisabled" kind of error.
type ErrAccountDisabled struct {
UserID int64
}
// IsErrAccountDisabled checks if an error is a ErrAccountDisabled.
func IsErrAccountDisabled(err error) bool {
_, ok := err.(*ErrAccountDisabled)
return ok
}
func (err *ErrAccountDisabled) Error() string {
return "Account is disabled"
}
// ErrCodeAccountDisabled holds the unique world-error code of this error
const ErrCodeAccountDisabled = 1020
// HTTPError holds the http error description
func (err *ErrAccountDisabled) HTTPError() web.HTTPError {
return web.HTTPError{
HTTPCode: http.StatusPreconditionFailed,
Code: ErrCodeAccountDisabled,
Message: "This account is disabled. Check your emails or ask your administrator.",
}
}