User registration

From NSB App Studio
Jump to navigation Jump to search

To sign a user up for your app, you'll need to get an email address and a password from them and send it to VoltServer. If enabled, VoltServer will send a confirmation email. Once the user registers, they will be able to sign on to your app.

Registering a User

Here's a typical user registration screen:

Once you've collected the data, you can call VoltServer using $volt.auth.register() function to register. This will create an account.

The syntax of the function is:

$volt.auth.register(email, password, confirmation, appId, callback)

  • email - string, required. The email address of the user.
  • password - string, required. The user's password.
  • confirmation - string, required. The confirmation password. Must match.
  • appId - string, optional. The VoltServer ID of the app to sign into. If not supplied, defaults to value set in $volt.init(appId).
  • callback - function(error, data), required. The function in your app to call when the register is complete (or fails).

After VoltServer receives the registration, it will send a confirmation email if you have enabled that functionality.

  butCreateAccount.onclick = function () {
    $volt.auth.register(inpEmail.value, inpPassword.value, inpPasswordConfirm.value, createAccountCallback);
  }

  function createAccountCallback(error, data) {
    if (error) {
      if (!data) {
        data = { message: 'Network Error' };
      }
      alert(data.message);
    } else {
      alert('Your account has been registered.');
    }
  }
  Function butCreateAccount_onclick() 
    $volt.auth.register(inpEmail.value, inpPassword.value, inpPasswordConfirm.value, createAccountCallback)
  End Function

  Function createAccountCallback(error, data) {
    If error Then
      If (!data) Then data = { message: "Network Error" }
      MsgBox data.message
    Else
      MsgBox "Your account has been registered."
    End If
  End Function

AppStudio Users

AppStudio includes a form called frmSignOn. If you include it in your app, a register form is included. To use it, do the following:

  showCreateAccount();
  showCreateAccount()

Reference