Closed leeaee closed 4 years ago
Fixed.
In order to support id, application need to set act configuration:
aaa.user.key=id
Another place app needs to change is it must pass userId
instead of username
when login a user, say if previous code is:
@PostAction("login")
public void login(String username, char[] password, ActionContext ctx, User.Dao userDao) {
notFoundIfNot(userDao.authenticate(username, password));
User user = userDao.findByUsername(username);
ctx.login(user.email);
}
The new code needs to be:
@PostAction("login")
public void login(String username, char[] password, ActionContext ctx, User.Dao userDao) {
notFoundIfNot(userDao.authenticate(username, password));
User user = userDao.findByUsername(username);
ctx.login(user.id);
}
The final part app needs to follow is the User
entity class must have either getter/setter for id
or a field named id
Now, act-aaa used 'username' as the login name for authentication. But in our system need support multip-login type such as 'phone', 'email' and allows the user to change the phone or email. We used userId as the foreign key in other object tables, not the username. In the scenario, act-aaa could not support the requirement.
Code example:
In database, we defined 'user_id' as user address table foreign key.
And in our logic, we also using 'userId' as linked value for userAddress
Could act-aaa add userId support for login and authentication?