[FEATURE][EXPERIMENTAL] AuthProviderDAOResult

This commit is contained in:
Gravit 2020-05-26 04:42:31 +07:00
parent bdecd57470
commit c353de9267
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
3 changed files with 27 additions and 1 deletions

View file

@ -0,0 +1,21 @@
package pro.gravit.launchserver.auth.provider;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launchserver.dao.User;
public class AuthProviderDAOResult extends AuthProviderResult {
public User daoObject;
public AuthProviderDAOResult(String username, String accessToken) {
super(username, accessToken);
}
public AuthProviderDAOResult(String username, String accessToken, ClientPermissions permissions) {
super(username, accessToken, permissions);
}
public AuthProviderDAOResult(String username, String accessToken, ClientPermissions permissions, User daoObject) {
super(username, accessToken, permissions);
this.daoObject = daoObject;
}
}

View file

@ -26,7 +26,7 @@ public AuthProviderResult auth(String login, AuthRequest.AuthPasswordInterface p
if (user == null) throw new AuthException("Username incorrect");
else throw new AuthException("Username or password incorrect");
}
return new AuthProviderResult(login, SecurityHelper.randomStringToken(), user.getPermissions());
return new AuthProviderDAOResult(login, SecurityHelper.randomStringToken(), user.getPermissions(), user);
}
@Override

View file

@ -8,6 +8,7 @@
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.auth.provider.AuthProvider;
import pro.gravit.launchserver.auth.provider.AuthProviderDAOResult;
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.response.SimpleResponse;
@ -84,6 +85,10 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
clientData.username = result.playerProfile.username;
else
clientData.username = login;
if(aresult instanceof AuthProviderDAOResult)
{
clientData.daoObject = ((AuthProviderDAOResult) aresult).daoObject;
}
result.accessToken = aresult.accessToken;
result.permissions = clientData.permissions;
if (getSession) {