forked from free-lancers/electricity_bill_calc_service
		
	fix(user):增加对于用户是否被禁用的判断。
This commit is contained in:
		| @@ -31,6 +31,9 @@ func (_UserService) ProcessEnterpriseUserLogin(username, password string) (*mode | |||||||
| 	if user.Type != 0 { | 	if user.Type != 0 { | ||||||
| 		return nil, exceptions.NewAuthenticationError(401, "用户类型不正确。") | 		return nil, exceptions.NewAuthenticationError(401, "用户类型不正确。") | ||||||
| 	} | 	} | ||||||
|  | 	if !user.Enabled { | ||||||
|  | 		return nil, exceptions.NewAuthenticationError(401, "用户已被禁用。") | ||||||
|  | 	} | ||||||
| 	hash := sha512.New512_256() | 	hash := sha512.New512_256() | ||||||
| 	hash.Write([]byte(password)) | 	hash.Write([]byte(password)) | ||||||
| 	hashedPassword := fmt.Sprintf("%x", hash.Sum(nil)) | 	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 { | 	if user.Type != 1 && user.Type != 2 { | ||||||
| 		return nil, exceptions.NewAuthenticationError(401, "用户类型不正确。") | 		return nil, exceptions.NewAuthenticationError(401, "用户类型不正确。") | ||||||
| 	} | 	} | ||||||
|  | 	if !user.Enabled { | ||||||
|  | 		return nil, exceptions.NewAuthenticationError(401, "用户已被禁用。") | ||||||
|  | 	} | ||||||
| 	hash := sha512.New512_256() | 	hash := sha512.New512_256() | ||||||
| 	hash.Write([]byte(password)) | 	hash.Write([]byte(password)) | ||||||
| 	hashedPassword := fmt.Sprintf("%x", hash.Sum(nil)) | 	hashedPassword := fmt.Sprintf("%x", hash.Sum(nil)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user