mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-09 09:09:46 +03:00
[FEATURE] Автоматическая регистрация при первом входе
This commit is contained in:
parent
4bb5993ef0
commit
2d887c86a9
2 changed files with 14 additions and 0 deletions
|
@ -7,9 +7,14 @@
|
|||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
public class HibernateAuthProvider extends AuthProvider {
|
||||
public boolean autoReg;
|
||||
@Override
|
||||
public AuthProviderResult auth(String login, String password, String ip) throws Exception {
|
||||
User user = srv.config.dao.userService.findUserByUsername(login);
|
||||
if(user == null && autoReg)
|
||||
{
|
||||
user = srv.config.dao.userService.registerNewUser(login, password);
|
||||
}
|
||||
if(user == null || !user.verifyPassword(password))
|
||||
{
|
||||
if(user ==null) throw new AuthException("Username incorrect");
|
||||
|
|
|
@ -24,6 +24,15 @@ public User findUserByUUID(UUID uuid) {
|
|||
return usersDao.findByUUID(uuid);
|
||||
}
|
||||
|
||||
public User registerNewUser(String username, String password)
|
||||
{
|
||||
User user = new User();
|
||||
user.username = username;
|
||||
user.setPassword(password);
|
||||
user.uuid = UUID.randomUUID();
|
||||
return user;
|
||||
}
|
||||
|
||||
public void saveUser(User user) {
|
||||
usersDao.save(user);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue