private void customRoomLogin(ISFSEvent event) throws SFSLoginException { trace("Game Login by session"); DBCollection users = AuthorizeExtension.users; BasicDBObject query = new BasicDBObject(); query.put("session", generateSession); DBCursor cursor = users.find(query); if (!cursor.hasNext()) { trace("Game Login User not found!", generateSession); SFSErrorData data = new SFSErrorData(SFSErrorCode.LOGIN_BAD_PASSWORD); data.addParameter(userName); throw new SFSLoginException("Login failed for user: "******"Game Login User logged in!", generateSession); document = cursor.next(); ISFSObject outData = (ISFSObject) event.getParameter(SFSEventParam.LOGIN_OUT_DATA); outData.putUtfString(SFSConstants.NEW_LOGIN_NAME, document.get("nickname").toString()); Boolean isGuest = (Boolean) document.get("is_guest"); if (isGuest == null) { isRegistered = true; } else { isRegistered = false; } } }
private void handleUser(ISFSEvent event) { trace("Registered user logged in", userName); DBCollection users = AuthorizeExtension.users; BasicDBObject query = new BasicDBObject(); query.put("email", userName); DBCursor cursor = users.find(query); if (!cursor.hasNext()) { trace("user not found"); return; } document = cursor.next(); String password_digest = (String) document.get("password_digest"); if (!getApi().checkSecurePassword(session, password_digest, cryptedPass)) { trace("password wrong"); return; } document.put("session", generateSession); users.update(query, document); isRegistered = true; }