fix(user):增加对于用户是否被禁用的判断。

This commit is contained in:
徐涛 2022-08-12 17:18:11 +08:00
parent fd9de54262
commit a9f281d4df

View File

@ -31,6 +31,9 @@ func (_UserService) ProcessEnterpriseUserLogin(username, password string) (*mode
if user.Type != 0 {
return nil, exceptions.NewAuthenticationError(401, "用户类型不正确。")
}
if !user.Enabled {
return nil, exceptions.NewAuthenticationError(401, "用户已被禁用。")
}
hash := sha512.New512_256()
hash.Write([]byte(password))
hashedPassword := fmt.Sprintf("%x", hash.Sum(nil))
@ -69,6 +72,9 @@ func (_UserService) ProcessManagementUserLogin(username, password string) (*mode
if user.Type != 1 && user.Type != 2 {
return nil, exceptions.NewAuthenticationError(401, "用户类型不正确。")
}
if !user.Enabled {
return nil, exceptions.NewAuthenticationError(401, "用户已被禁用。")
}
hash := sha512.New512_256()
hash.Write([]byte(password))
hashedPassword := fmt.Sprintf("%x", hash.Sum(nil))