Skip to content
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

fix: Fix the problem that users cannot login using uid #75

Merged
merged 1 commit into from
Mar 13, 2024
Merged
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
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
Loading