mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-09 00:59:44 +03:00
[FEATURE] Команда GetUserPassword меняющая пароль пользователя
This commit is contained in:
parent
952279b1f4
commit
248bead428
4 changed files with 42 additions and 1 deletions
|
@ -26,7 +26,7 @@ public void invoke(String... args) throws Exception {
|
|||
User user = server.userService.findUserByUsername(args[0]);
|
||||
if(user == null)
|
||||
{
|
||||
LogHelper.error("User %s not found", args[1]);
|
||||
LogHelper.error("User %s not found", args[0]);
|
||||
return;
|
||||
}
|
||||
LogHelper.info("[%s] UUID: %s", user.username, user.uuid.toString());
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.launchserver.dao.User;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -29,5 +30,6 @@ public void invoke(String... args) throws Exception {
|
|||
user.setPassword(args[1]);
|
||||
user.uuid = UUID.randomUUID();
|
||||
LaunchServer.server.userService.saveUser(user);
|
||||
LogHelper.info("User %s registered. UUID: %s", user.username, user.uuid.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package pro.gravit.launchserver.command.dao;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.launchserver.dao.User;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class SetUserPasswordCommand extends Command {
|
||||
|
||||
public SetUserPasswordCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgsDescription() {
|
||||
return "[username] [new password]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsageDescription() {
|
||||
return "Set user password";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
verifyArgs(args, 2);
|
||||
User user = server.userService.findUserByUsername(args[0]);
|
||||
if(user == null)
|
||||
{
|
||||
LogHelper.error("User %s not found", args[1]);
|
||||
return;
|
||||
}
|
||||
user.setPassword(args[1]);
|
||||
server.userService.updateUser(user);
|
||||
LogHelper.info("[%s] UUID: %s | New Password: %s", user.username, user.uuid.toString(), args[1]);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
import pro.gravit.launchserver.command.dao.GetAllUsersCommand;
|
||||
import pro.gravit.launchserver.command.dao.GetUserCommand;
|
||||
import pro.gravit.launchserver.command.dao.RegisterCommand;
|
||||
import pro.gravit.launchserver.command.dao.SetUserPasswordCommand;
|
||||
import pro.gravit.launchserver.command.hash.*;
|
||||
import pro.gravit.launchserver.command.install.CheckInstallCommand;
|
||||
import pro.gravit.launchserver.command.install.MultiCommand;
|
||||
|
@ -63,6 +64,7 @@ public static void registerCommands(pro.gravit.utils.command.CommandHandler hand
|
|||
//Register dao commands
|
||||
BaseCommandCategory dao = new BaseCommandCategory();
|
||||
dao.registerCommand("register", new RegisterCommand(server));
|
||||
dao.registerCommand("setUserPassword", new SetUserPasswordCommand(server));
|
||||
dao.registerCommand("getUser", new GetUserCommand(server));
|
||||
dao.registerCommand("getAllUsers", new GetAllUsersCommand(server));
|
||||
Category daoCategory = new Category(dao, "DAO", "Data Management");
|
||||
|
|
Loading…
Reference in a new issue