优化结构

This commit is contained in:
Yvan
2026-08-28 10:51:19 +08:00
parent fec3820464
commit 5b17f47141
12 changed files with 63 additions and 31 deletions
+6 -1
View File
@@ -152,7 +152,12 @@ func (uc *AuthenticationUsecase) Login(ctx context.Context, attempt *LoginAttemp
return nil, fmt.Errorf("%w: %v", ErrLoginState, cacheErr)
}
}
return &AuthenticationResult{User: user, Token: issued.Value, ExpiresAt: issued.ExpiresAt, NeedChangePassword: user.MustChangePassword}, nil
// AuthenticationResult crosses the biz/service boundary; never retain the
// credential hash in the user object returned to transport code. Keep the
// repository-owned value untouched in case another caller shares it.
resultUser := *user
resultUser.Password = ""
return &AuthenticationResult{User: &resultUser, Token: issued.Value, ExpiresAt: issued.ExpiresAt, NeedChangePassword: resultUser.MustChangePassword}, nil
}
func userHasAuthority(user *User, authorityID uint) bool {