fix(user):更正表示用户登录错误的错误码。

This commit is contained in:
徐涛 2022-09-02 09:52:02 +08:00
parent 7abf35ca97
commit 17bde54c7c

View File

@ -30,14 +30,14 @@ func (u _UserService) ProcessEnterpriseUserLogin(username, password string) (*mo
return nil, exceptions.NewAuthenticationError(404, "用户不存在。") return nil, exceptions.NewAuthenticationError(404, "用户不存在。")
} }
if user.Type != 0 { if user.Type != 0 {
return nil, exceptions.NewAuthenticationError(401, "用户类型不正确。") return nil, exceptions.NewAuthenticationError(400, "用户类型不正确。")
} }
if !user.Enabled { if !user.Enabled {
return nil, exceptions.NewAuthenticationError(401, "用户已被禁用。") return nil, exceptions.NewAuthenticationError(403, "用户已被禁用。")
} }
hashedPassword := utils.Sha512Hex(password) hashedPassword := utils.Sha512Hex(password)
if hashedPassword != user.Password { if hashedPassword != user.Password {
return nil, exceptions.NewAuthenticationError(401, "用户凭据不正确。") return nil, exceptions.NewAuthenticationError(402, "用户凭据不正确。")
} }
if user.ResetNeeded { if user.ResetNeeded {
authErr := exceptions.NewAuthenticationError(401, "用户凭据已失效。") authErr := exceptions.NewAuthenticationError(401, "用户凭据已失效。")
@ -46,7 +46,7 @@ func (u _UserService) ProcessEnterpriseUserLogin(username, password string) (*mo
} }
userDetial, _ := u.retreiveUserDetail(user.Id) userDetial, _ := u.retreiveUserDetail(user.Id)
if userDetial.ServiceExpiration.Before(time.Now()) { if userDetial.ServiceExpiration.Before(time.Now()) {
return nil, exceptions.NewAuthenticationError(401, "用户服务期限已过。") return nil, exceptions.NewAuthenticationError(406, "用户服务期限已过。")
} }
session := &model.Session{ session := &model.Session{
Token: uuid.New().String(), Token: uuid.New().String(),