app/models/Users.java
public Map<String, Object> userSignUp(final SignUpDTO requestDTO) throws Exception {
		Ebean.beginTransaction();
		Map<String, Object> signUpResponse = null;
		try{
			Users newUser = null;
			// Validate inputs
			if(requestDTO.userName.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_USER_NAME.toString());
			}
			if(requestDTO.email.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_EMAIL.toString());
			}
			String hashedPassword = null;
			if(requestDTO.password.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_PASSWORD.toString());
			} else {
				hashedPassword = SecureDigester.digest(requestDTO.password);
			}
			// Check if user already exists
			Users existingUser = findUserByEmail(requestDTO.email);
			if(existingUser != null) {
				throw new YmlException(EnumMessages.USER_WITH_EMAIL_ALREADY_SIGNED_UP.toString());
			}

			newUser = new Users();
			newUser.email = requestDTO.email;
			newUser.userName = requestDTO.userName;
			newUser.password = hashedPassword;
			newUser.createdDate = new Date().getTime();
			Ebean.insert(newUser);
			
			// Create session
			UserSession userSession = new UserSession();
			String sessionToken = userSession.createSession(newUser);
			if(sessionToken == null){
				throw new YmlException(EnumMessages.USER_SESSION_NOT_CREATED.toString());
			}
			signUpResponse = new HashMap<>();
			signUpResponse.put(ApiResponseKeys.USER_ID.toString(), newUser.id);
			signUpResponse.put(ApiResponseKeys.USER_NAME.toString(), newUser.userName);
			signUpResponse.put(ApiResponseKeys.EMAIL.toString(), newUser.email);
			signUpResponse.put(ApiResponseKeys.SESSION_TOKEN.toString(), sessionToken);
			
			Ebean.commitTransaction();
		} finally {
			if (Ebean.currentTransaction() != null) {
				Ebean.currentTransaction().rollback();
			}
		}
	
		
		return signUpResponse;
	}
/**
	 * Insert user for sign up 
	 * @throws Exception 
	 */
Insert user for sign up
@throws Exception
Insert user for sign up @throws Exception
public Map<String, Object> userSignUp(final SignUpDTO requestDTO) throws Exception {
		Ebean.beginTransaction();
		Map<String, Object> signUpResponse = null;
		try{
			Users newUser = null;
			if(requestDTO.userName.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_USER_NAME.toString());
			}
			if(requestDTO.email.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_EMAIL.toString());
			}
			String hashedPassword = null;
			if(requestDTO.password.isEmpty()) {
				throw new YmlException(EnumMessages.ENTER_PASSWORD.toString());
			} else {
				hashedPassword = SecureDigester.digest(requestDTO.password);
			}
			Users existingUser = findUserByEmail(requestDTO.email);
			if(existingUser != null) {
				throw new YmlException(EnumMessages.USER_WITH_EMAIL_ALREADY_SIGNED_UP.toString());
			}
			newUser = new Users();
			newUser.email = requestDTO.email;
			newUser.userName = requestDTO.userName;
			newUser.password = hashedPassword;
			newUser.createdDate = new Date().getTime();
			Ebean.insert(newUser);
			UserSession userSession = new UserSession();
			String sessionToken = userSession.createSession(newUser);
			if(sessionToken == null){
				throw new YmlException(EnumMessages.USER_SESSION_NOT_CREATED.toString());
			}
			signUpResponse = new HashMap<>();
			signUpResponse.put(ApiResponseKeys.USER_ID.toString(), newUser.id);
			signUpResponse.put(ApiResponseKeys.USER_NAME.toString(), newUser.userName);
			signUpResponse.put(ApiResponseKeys.EMAIL.toString(), newUser.email);
			signUpResponse.put(ApiResponseKeys.SESSION_TOKEN.toString(), sessionToken);
			Ebean.commitTransaction();
		} finally {
			if (Ebean.currentTransaction() != null) {
				Ebean.currentTransaction().rollback();
			}
		}
		return signUpResponse;
	}
public Map < String , Object > userSignUp ( final SignUpDTO requestDTO ) throws Exception { Ebean . beginTransaction ( ) ; Map < String , Object > signUpResponse = null ; try { Users newUser = null ; if ( requestDTO . userName . isEmpty ( ) ) { throw new YmlException ( EnumMessages . ENTER_USER_NAME . toString ( ) ) ; } if ( requestDTO . email . isEmpty ( ) ) { throw new YmlException ( EnumMessages . ENTER_EMAIL . toString ( ) ) ; } String hashedPassword = null ; if ( requestDTO . password . isEmpty ( ) ) { throw new YmlException ( EnumMessages . ENTER_PASSWORD . toString ( ) ) ; } else { hashedPassword = SecureDigester . digest ( requestDTO . password ) ; } Users existingUser = findUserByEmail ( requestDTO . email ) ; if ( existingUser != null ) { throw new YmlException ( EnumMessages . USER_WITH_EMAIL_ALREADY_SIGNED_UP . toString ( ) ) ; } newUser = new Users ( ) ; newUser . email = requestDTO . email ; newUser . userName = requestDTO . userName ; newUser . password = hashedPassword ; newUser . createdDate = new Date ( ) . getTime ( ) ; Ebean . insert ( newUser ) ; UserSession userSession = new UserSession ( ) ; String sessionToken = userSession . createSession ( newUser ) ; if ( sessionToken == null ) { throw new YmlException ( EnumMessages . USER_SESSION_NOT_CREATED . toString ( ) ) ; } signUpResponse = new HashMap < > ( ) ; signUpResponse . put ( ApiResponseKeys . USER_ID . toString ( ) , newUser . id ) ; signUpResponse . put ( ApiResponseKeys . USER_NAME . toString ( ) , newUser . userName ) ; signUpResponse . put ( ApiResponseKeys . EMAIL . toString ( ) , newUser . email ) ; signUpResponse . put ( ApiResponseKeys . SESSION_TOKEN . toString ( ) , sessionToken ) ; Ebean . commitTransaction ( ) ; } finally { if ( Ebean . currentTransaction ( ) != null ) { Ebean . currentTransaction ( ) . rollback ( ) ; } } return signUpResponse ; }
Insert user for sign up
 @throws Exception
Insert user for sign up @throws Exception
// Validate inputs // Check if user already exists // Create session