app/controllers/UserController.java
/**
     * Handle Android Registration submission.
     * The response to Volley is what is needed here.
     * Play Actions only return Result types which are HTTP codes.
     */
Handle Android Registration submission.
The response to Volley is what is needed here.
Play Actions only return Result types which are HTTP codes.
Handle Android Registration submission . The response to Volley is what is needed here . Play Actions only return Result types which are HTTP codes .
public Result saveAndroidUser() {
        List<ValidationError> errors = new ArrayList<>();
        Form<User> registerForm = formFactory.form(User.class).bindFromRequest();
        User user = null;
        String username = registerForm.get().username;
        String password = registerForm.get().password;
        user = User.authenticate(username, password); 
        if(user != null){
            System.out.println("Username not unique error");
            errors.add(new ValidationError("username", "username must be unique."));
            registerForm.errors().put("",errors);
        }
        if(registerForm.hasErrors()) {
            System.out.println("Username Already Exists.");
            return ok("ERRORS");
        }
        registerForm.get().save();
        System.out.println("Android User added to DB.");
        return ok("USER_CREATED");
    }
public Result saveAndroidUser ( ) { List < ValidationError > errors = new ArrayList < > ( ) ; Form < User > registerForm = formFactory . form ( User . class ) . bindFromRequest ( ) ; User user = null ; String username = registerForm . get ( ) . username ; String password = registerForm . get ( ) . password ; user = User . authenticate ( username , password ) ; if ( user != null ) { System . out . println ( "Username not unique error" ) ; errors . add ( new ValidationError ( "username" , "username must be unique." ) ) ; registerForm . errors ( ) . put ( "" , errors ) ; } if ( registerForm . hasErrors ( ) ) { System . out . println ( "Username Already Exists." ) ; return ok ( "ERRORS" ) ; } registerForm . get ( ) . save ( ) ; System . out . println ( "Android User added to DB." ) ; return ok ( "USER_CREATED" ) ; }
Handle Android Registration submission.
Handle Android Registration submission .
//Reuse authenticate to check unique username.