Skip to content

Shouldn't return error if IsErrUserNotExist #22353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion services/auth/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ func (b *Basic) Verify(req *http.Request, w http.ResponseWriter, store DataStore
if err != nil {
if !user_model.IsErrUserNotExist(err) {
log.Error("UserSignIn: %v", err)
return nil, err
}
return nil, err
return nil, nil
}

if skipper, ok := source.Cfg.(LocalTwoFASkipper); ok && skipper.IsSkipLocalTwoFA() {
Expand Down
3 changes: 2 additions & 1 deletion services/auth/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ func (o *OAuth2) Verify(req *http.Request, w http.ResponseWriter, store DataStor
if err != nil {
if !user_model.IsErrUserNotExist(err) {
log.Error("GetUserByName: %v", err)
return nil, err
}
return nil, err
return nil, nil
}

log.Trace("OAuth2 Authorization: Logged in user %-v", user)
Expand Down
5 changes: 4 additions & 1 deletion services/auth/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ func (r *ReverseProxy) getUserFromAuthUser(req *http.Request) (*user_model.User,

user, err := user_model.GetUserByName(req.Context(), username)
if err != nil {
if !user_model.IsErrUserNotExist(err) || !r.isAutoRegisterAllowed() {
if !user_model.IsErrUserNotExist(err) {
log.Error("GetUserByName: %v", err)
return nil, err
}
if !r.isAutoRegisterAllowed() {
return nil, nil
}
user = r.newUser(req)
}
return user, nil
Expand Down