Skip to content

Commit

Permalink
fix: Fix the problem that users cannot login using uid
Browse files Browse the repository at this point in the history
  • Loading branch information
Xunop committed Mar 13, 2024
1 parent c4a9cca commit 9489bde
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,16 @@ func VerifyAccountRegister(ctx *gin.Context, username string) (string, error) {
// This username is email or uid
func VerifyAccountLogin(ctx *gin.Context, username string) (string, error) {
var user *model.User
user, err := model.GetUserByEmail(username)

// User use email to login, need to trasfer to uid
split := regexp.MustCompile(`@`)
username = split.Split(username, 2)[0]

user, err := model.GetUserByUid(username)
if err != nil || user == nil {
return "", result.UserNotExist
}

if user == nil {
user, err := model.GetUserByUid(username)
if err != nil || user == nil {
return "", result.UserNotExist
}
}

ticket, err := util.GenerateTokenWithExp(ctx, model.LoginTicketJWTSubKey(*user.Uid), model.LOGIN_TICKET_EXP)
if err != nil || ticket == "" {
return "", err
Expand Down

0 comments on commit 9489bde

Please sign in to comment.