paascloud/paascloud-master · error · BadCredentialsException
用户名不存在或者密码错误
Error message
用户名不存在或者密码错误
What it means
UacUserDetailsServiceImpl.loadUserByUsername throws BadCredentialsException("用户名不存在或者密码错误") when uacUserService.findByLoginName(username) returns null during Spring Security authentication. Spring Security deliberately reports a generic message so attackers cannot distinguish unknown usernames from wrong passwords.
Solutions
- Verify the exact loginName exists: SELECT * FROM uac_user WHERE login_name = ?
- Confirm the user is registering/logging in with the loginName field, not email or mobile
- Check for leading/trailing spaces or case differences in the submitted username
- If the account should exist, re-register or restore the user record
Example fix
// before
uacUserService.login("john@example.com", pwd); // email used as loginName
// after
UacUser u = uacUserService.findByLoginName("john"); // use the actual login_name column value Defensive patterns
Strategy: try-catch
Validate before calling
boolean exists = userService.findByLoginName(username) != null; // or SELECT 1 FROM uac_user WHERE login_name = ?
Try / catch
try { authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password)); } catch (BadCredentialsException e) { throw new LoginException("用户名不存在或者密码错误"); } Prevention
- Always authenticate with the login_name column value, not email or phone
- Trim and normalize username input before submitting
- Provide clear UI feedback that distinguishes 'check credentials' without leaking which part was wrong
- Seed test users in every environment's DB before running integration tests
When it happens
Trigger: Authenticating (form login or the /user/login flow) with a loginName that has no matching row in the uac_user table.
Common situations: User typed wrong username or an email/phone instead of loginName; user never registered or was soft-deleted; case-sensitivity mismatch in login name; connecting to a DB where the account does not exist.
Understand the failure class
Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.
Related errors
- Authentication method not supported:
- Authentication method not supported:
- UAC10011041
- UAC10011039
- UAC10011040
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/a04a161f7318b6db.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/security/UacUserDetailsServiceImpl.java:38
@Component
public class UacUserDetailsServiceImpl implements UserDetailsService {
@Resource
private UacUserService uacUserService;
/**
* Load user by username user details.
*
* @param username the username
*
* @return the user details
*/
@Override
public UserDetails loadUserByUsername(String username) {
Collection<GrantedAuthority> grantedAuthorities;
UacUser user = uacUserService.findByLoginName(username);
if (user == null) {
throw new BadCredentialsException("用户名不存在或者密码错误");
}
user = uacUserService.findUserInfoByUserId(user.getId());
grantedAuthorities = uacUserService.loadUserAuthorities(user.getId());
return new SecurityUser(user.getId(), user.getLoginName(), user.getLoginPwd(),
user.getUserName(), user.getGroupId(), user.getGroupName(), user.getStatus(), grantedAuthorities);
}
}
View on GitHub (pinned to 781281a950)