mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE][EXPERIMENTAL] AuthProviderDAOResult
This commit is contained in:
parent
bdecd57470
commit
c353de9267
3 changed files with 27 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue