mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
Merge branch 'dev' of github.com:GravitLauncher/Launcher into dev
This commit is contained in:
commit
a93748b6c6
12 changed files with 89 additions and 35 deletions
|
@ -30,6 +30,7 @@ public class User {
|
|||
private long id;
|
||||
@Column(unique = true)
|
||||
public String username;
|
||||
public String email;
|
||||
@Column(unique = true)
|
||||
public UUID uuid;
|
||||
@Column(name = "password")
|
||||
|
|
|
@ -20,14 +20,7 @@
|
|||
import pro.gravit.launchserver.socket.response.WebSocketServerResponse;
|
||||
import pro.gravit.launchserver.socket.response.admin.AddLogListenerResponse;
|
||||
import pro.gravit.launchserver.socket.response.admin.ExecCommandResponse;
|
||||
import pro.gravit.launchserver.socket.response.auth.AuthResponse;
|
||||
import pro.gravit.launchserver.socket.response.auth.CheckServerResponse;
|
||||
import pro.gravit.launchserver.socket.response.auth.GetAvailabilityAuthResponse;
|
||||
import pro.gravit.launchserver.socket.response.auth.JoinServerResponse;
|
||||
import pro.gravit.launchserver.socket.response.auth.ProfilesResponse;
|
||||
import pro.gravit.launchserver.socket.response.auth.RegisterResponse;
|
||||
import pro.gravit.launchserver.socket.response.auth.RestoreSessionResponse;
|
||||
import pro.gravit.launchserver.socket.response.auth.SetProfileResponse;
|
||||
import pro.gravit.launchserver.socket.response.auth.*;
|
||||
import pro.gravit.launchserver.socket.response.profile.BatchProfileByUsername;
|
||||
import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse;
|
||||
import pro.gravit.launchserver.socket.response.profile.ProfileByUsername;
|
||||
|
@ -130,6 +123,7 @@ public static void registerResponses() {
|
|||
providers.register("verifySecureToken", VerifySecureTokenResponse.class);
|
||||
providers.register("getAvailabilityAuth", GetAvailabilityAuthResponse.class);
|
||||
providers.register("register", RegisterResponse.class);
|
||||
providers.register("setPassword", SetPasswordResponse.class);
|
||||
}
|
||||
|
||||
public void sendObject(ChannelHandlerContext ctx, Object obj) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
public class RegisterResponse extends SimpleResponse {
|
||||
public String login;
|
||||
public String password;
|
||||
public String email;
|
||||
public byte[] verifyHash;
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception
|
||||
|
@ -32,6 +33,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception
|
|||
}
|
||||
User user = new User();
|
||||
user.username = login;
|
||||
user.email = email;
|
||||
user.setPassword(password);
|
||||
user.uuid = UUID.randomUUID();
|
||||
server.config.dao.userService.saveUser(user);
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package pro.gravit.launchserver.socket.response.auth;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import pro.gravit.launcher.events.request.SetPasswordRequestEvent;
|
||||
import pro.gravit.launchserver.dao.User;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
|
||||
public class SetPasswordResponse extends SimpleResponse {
|
||||
public String oldPassword;
|
||||
public String newPassword;
|
||||
public String username;
|
||||
@Override
|
||||
public String getType() {
|
||||
return "setPassword";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
if(( oldPassword == null && username == null ) || newPassword == null)
|
||||
{
|
||||
sendError("Request invalid");
|
||||
return;
|
||||
}
|
||||
if(!client.isAuth)
|
||||
{
|
||||
sendError("You not authorized");
|
||||
return;
|
||||
}
|
||||
if(username != null && !client.permissions.canAdmin)
|
||||
{
|
||||
sendError("You not admin");
|
||||
return;
|
||||
}
|
||||
if(username != null)
|
||||
{
|
||||
User user = server.config.dao.userService.findUserByUsername(username);
|
||||
user.setPassword(newPassword);
|
||||
sendResult(new SetPasswordRequestEvent());
|
||||
}
|
||||
else
|
||||
{
|
||||
User user = server.config.dao.userService.findUserByUsername(client.username);
|
||||
if(user.verifyPassword(oldPassword))
|
||||
{
|
||||
user.setPassword(newPassword);
|
||||
sendResult(new SetPasswordRequestEvent());
|
||||
}
|
||||
else
|
||||
{
|
||||
sendError("Old password incorrect");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -111,13 +111,13 @@ public void start(String... args) throws Throwable {
|
|||
}
|
||||
};
|
||||
}
|
||||
LauncherGuardManager.initGuard(false);
|
||||
if(UpdateRequest.getController() == null) UpdateRequest.setController(new LauncherUpdateController());
|
||||
Objects.requireNonNull(args, "args");
|
||||
if (started.getAndSet(true))
|
||||
throw new IllegalStateException("Launcher has been already started");
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientEngineInitPhase(this));
|
||||
runtimeProvider.preLoad();
|
||||
LauncherGuardManager.initGuard(false);
|
||||
FunctionalBridge.getHWID = CommonHelper.newThread("GetHWID Thread", true, FunctionalBridge::getHWID);
|
||||
FunctionalBridge.getHWID.start();
|
||||
LogHelper.debug("Dir: %s", DirBridge.dir);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package pro.gravit.launcher.events.request;
|
||||
|
||||
import pro.gravit.launcher.events.RequestEvent;
|
||||
|
||||
public class SetPasswordRequestEvent extends RequestEvent {
|
||||
@Override
|
||||
public String getType() {
|
||||
return "setPassword";
|
||||
}
|
||||
}
|
|
@ -127,8 +127,8 @@ public LauncherModule preInit()
|
|||
* Modify module description, dependencies
|
||||
* Add modules
|
||||
* Read configuration
|
||||
* @param initContext <tr>null</tr> on module initialization during boot or startup
|
||||
* Not <tr>null</tr> during module initialization while running
|
||||
* @param initContext <b>null</b> on module initialization during boot or startup
|
||||
* Not <b>null</b> during module initialization while running
|
||||
*/
|
||||
public abstract void init(LauncherInitContext initContext);
|
||||
|
||||
|
|
|
@ -12,25 +12,7 @@
|
|||
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.events.ExceptionEvent;
|
||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import pro.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent;
|
||||
import pro.gravit.launcher.events.request.CheckServerRequestEvent;
|
||||
import pro.gravit.launcher.events.request.ErrorRequestEvent;
|
||||
import pro.gravit.launcher.events.request.ExecCommandRequestEvent;
|
||||
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
|
||||
import pro.gravit.launcher.events.request.GetSecureTokenRequestEvent;
|
||||
import pro.gravit.launcher.events.request.JoinServerRequestEvent;
|
||||
import pro.gravit.launcher.events.request.LauncherRequestEvent;
|
||||
import pro.gravit.launcher.events.request.LogEvent;
|
||||
import pro.gravit.launcher.events.request.ProfileByUUIDRequestEvent;
|
||||
import pro.gravit.launcher.events.request.ProfileByUsernameRequestEvent;
|
||||
import pro.gravit.launcher.events.request.ProfilesRequestEvent;
|
||||
import pro.gravit.launcher.events.request.RegisterRequestEvent;
|
||||
import pro.gravit.launcher.events.request.RestoreSessionRequestEvent;
|
||||
import pro.gravit.launcher.events.request.SetProfileRequestEvent;
|
||||
import pro.gravit.launcher.events.request.UpdateListRequestEvent;
|
||||
import pro.gravit.launcher.events.request.UpdateRequestEvent;
|
||||
import pro.gravit.launcher.events.request.VerifySecureTokenRequestEvent;
|
||||
import pro.gravit.launcher.events.request.*;
|
||||
import pro.gravit.launcher.hasher.HashedEntry;
|
||||
import pro.gravit.launcher.hasher.HashedEntryAdapter;
|
||||
import pro.gravit.launcher.request.WebSocketEvent;
|
||||
|
@ -126,6 +108,7 @@ public void registerResults() {
|
|||
results.register("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class);
|
||||
results.register("exception", ExceptionEvent.class);
|
||||
results.register("register", RegisterRequestEvent.class);
|
||||
results.register("setpassword", SetPasswordRequestEvent.class);
|
||||
}
|
||||
|
||||
public void registerHandler(EventHandler eventHandler) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import javax.net.ssl.SSLException;
|
||||
|
||||
import pro.gravit.launcher.events.ExceptionEvent;
|
||||
import pro.gravit.launcher.events.request.ErrorRequestEvent;
|
||||
import pro.gravit.launcher.request.Request;
|
||||
import pro.gravit.launcher.request.RequestException;
|
||||
|
@ -67,6 +68,10 @@ public WebSocketEvent get() throws InterruptedException, ExecutionException {
|
|||
ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) event.result;
|
||||
throw new ExecutionException(new RequestException(errorRequestEvent.error));
|
||||
}
|
||||
if (event.result.getType().equals("exception")) {
|
||||
ExceptionEvent error = (ExceptionEvent) event.result;
|
||||
throw new ExecutionException(new RequestException(String.format("LaunchServer fatal error: %s: %s", error.clazz, error.message)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -80,10 +85,14 @@ public WebSocketEvent get(long timeout, TimeUnit unit) throws InterruptedExcepti
|
|||
}
|
||||
WebSocketEvent result = event.result;
|
||||
waitEventHandler.requests.remove(event);
|
||||
if (event.result.getType().equals("error") || event.result.getType().equals("exception")) {
|
||||
if (event.result.getType().equals("error")) {
|
||||
ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) event.result;
|
||||
throw new ExecutionException(new RequestException(errorRequestEvent.error));
|
||||
}
|
||||
if (event.result.getType().equals("exception")) {
|
||||
ExceptionEvent error = (ExceptionEvent) event.result;
|
||||
throw new ExecutionException(new RequestException(String.format("LaunchServer fatal error: %s: %s", error.clazz, error.message)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ public final class Version {
|
|||
public final Type release;
|
||||
public static final int MAJOR = 5;
|
||||
public static final int MINOR = 0;
|
||||
public static final int PATCH = 7;
|
||||
public static final int PATCH = 8;
|
||||
public static final int BUILD = 1;
|
||||
public static final Version.Type RELEASE = Version.Type.DEV;
|
||||
public static final Version.Type RELEASE = Type.DEV;
|
||||
|
||||
@LauncherAPI
|
||||
public Version(int major, int minor, int patch) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
id 'signing'
|
||||
}
|
||||
group = 'pro.gravit.launcher'
|
||||
version = '5.0.7-SNAPSHOT'
|
||||
version = '5.0.8-SNAPSHOT'
|
||||
|
||||
configure(subprojects.findAll { it.name != 'modules' }) {
|
||||
apply plugin: 'idea'
|
||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
|||
Subproject commit 577d7c53dd972d8a5988bd02357b7d4458e30bbf
|
||||
Subproject commit 34f3eb73b471d1ac2fcf6661d61e7fd3af530b7f
|
Loading…
Reference in a new issue