mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-15 21:58:15 +00:00
Merge 13a2383597
into 4dca869ed1
This commit is contained in:
commit
cbeb91e311
@ -42,16 +42,13 @@ func (source *Source) Authenticate(ctx context.Context, user *user_model.User, u
|
||||
}
|
||||
|
||||
if err := Authenticate(auth, source); err != nil {
|
||||
// Check standard error format first,
|
||||
// then fallback to worse case.
|
||||
tperr, ok := err.(*textproto.Error)
|
||||
if (ok && tperr.Code == 535) ||
|
||||
strings.Contains(err.Error(), "Username and Password not accepted") {
|
||||
return nil, user_model.ErrUserNotExist{Name: userName}
|
||||
}
|
||||
if (ok && tperr.Code == 534) ||
|
||||
strings.Contains(err.Error(), "Application-specific password required") {
|
||||
return nil, user_model.ErrUserNotExist{Name: userName}
|
||||
// when authentication via smtp fails, wraps ErrInvalidArgument
|
||||
// with the original textproto.Error as the cause,
|
||||
// so it will show username_password_incorrect to the user
|
||||
// while log the original error so that admin can check.
|
||||
// see: routers/web/auth/auth.go SiginPost
|
||||
if tperr, ok := err.(*textproto.Error); ok {
|
||||
return nil, errors.Join(util.ErrInvalidArgument, tperr)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user