Skip to content

Commit

Permalink
Fix the bug of RedisAuthUser
Browse files Browse the repository at this point in the history
Signed-off-by: loheagn <[email protected]>
  • Loading branch information
loheagn committed Sep 18, 2022
1 parent 0d4d5f9 commit 75cfcb5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/context/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,16 @@ func RedisAuthUser(token string, createIfNotExist bool) (*db.User, error) {
if err != nil {
return nil, err
}
user, err := db.GetUserByStudentID(studentID)
user, err := db.GetUserByName(studentID)
if err != nil {
if _, ok := err.(db.ErrUserNotExist); ok && createIfNotExist {
return db.CreateDefaultUserByStudentID(studentID)
if _, ok := err.(db.ErrUserNotExist); ok {
if user, err = db.GetUserByStudentID(studentID); err != nil {
if _, ok := err.(db.ErrUserNotExist); ok && createIfNotExist {
return db.CreateDefaultUserByStudentID(studentID)
}
return nil, err
}
return user, nil
}
return nil, err
}
Expand Down

0 comments on commit 75cfcb5

Please sign in to comment.