added register constructor method

This commit is contained in:
Dave
2015-06-28 21:48:00 +02:00
parent bd931e1dce
commit 6ff5e60046
2 changed files with 7 additions and 4 deletions

View File

@@ -20,4 +20,9 @@ package nodash.core;
public final class NoRegister { public final class NoRegister {
public byte[] cookie; public byte[] cookie;
public byte[] data; public byte[] data;
public NoRegister(byte[] cookie, byte[] data) {
this.cookie = cookie;
this.data = data;
}
} }

View File

@@ -176,12 +176,11 @@ public final class NoSessionSphere {
} }
public static synchronized NoRegister registerUser(NoUser user, char[] password) { public static synchronized NoRegister registerUser(NoUser user, char[] password) {
NoRegister result = new NoRegister();
NoSession session = new NoSession(user); NoSession session = new NoSession(user);
NoSessionSphere.sessions.put(session.uuid, session); NoSessionSphere.sessions.put(session.uuid, session);
result.cookie = session.getEncryptedUUID();
try { try {
result.data = NoSessionSphere.save(result.cookie, password); byte[] cookie = session.getEncryptedUUID();
return new NoRegister(cookie, NoSessionSphere.save(cookie, password));
} catch (NoDashSessionBadUUIDException e) { } catch (NoDashSessionBadUUIDException e) {
throw new NoDashFatalException("Immediately generated cookie throwing bad cookie error.", e); throw new NoDashFatalException("Immediately generated cookie throwing bad cookie error.", e);
} catch (NoSessionExpiredException e) { } catch (NoSessionExpiredException e) {
@@ -196,6 +195,5 @@ public final class NoSessionSphere {
throw new NoDashFatalException( throw new NoDashFatalException(
"Session claims to be awaiting confirmation before returning data to the user.", e); "Session claims to be awaiting confirmation before returning data to the user.", e);
} }
return result;
} }
} }