Creation for user model and rule for user registration “sign up”

 

Here is the code used in this lesson:


Model User {
    String name
    String password
    Integer score value(0)
}

RuleContext SignUpContext {
    Rule createAccount {
        SignUp signUpExp = broker.ui.getDataSource()
        User newUser = User()
        newUser.name = signUpExp.username
        newUser.password = signUpExp.password
        broker.cloudPersistence.save(newUser)
        broker.ui.showAlert("Congratulations!", "Your account has been created successfully, please login now.")
        broker.ui.pop()
     }
}

> Next