User Registration¶
The user registration API can be used to create user accounts in the application. A registration request must provide a user object as a collection of key/value properties. The collection must contain all the required properties which must include a property marked as identity as well as the "password"
property. The default identity property is "email
", however, it can be changed in Backendless Console. Additionally, the "email"
property is required if the application is configured to confirm email addresses for the registered users.
When this API is used to convert a guest user account to a regular registered user, the BackendlessUser
argument must have the objectId
property set to the value returned from the Guest Login API.
¶
Backendless.UserService.register( user ) .then( function( registeredUser ) { }) .catch( function( error ) { });
where:
Argument | Description |
---|---|
user |
an instance of the Backendless.User class which contains property values for the account registration. |
Error Codes¶
The following errors may occur during User Registration API calls. See the Error Handling section for details on how to retrieve the error code when the server returns an error.
Error Code |
Description |
---|---|
2002 |
Invalid application info (application id or api key) |
3009 |
User registration is disabled for the application |
3010 |
User registration has an unknown property and dynamic properties are disabled for this version of the application |
3011 |
Missing "password" property |
3012 |
Required property is missing |
3013 |
Missing value for the identity property |
3014 |
External registration failed with an error. |
3021 |
General user registration error. Details included with the error message. |
3033 |
User with the same identity already exists |
3038 |
Missing application-id or collection of properties for the registering user |
3039 |
Property "id" cannot be used in the registration call |
3040 |
Email address is in the wrong format |
3041 |
A value for a required property is missing |
3043 |
Duplicate properties in the registration request |
8000 |
Property value exceeds the length limit |
Example¶
// do not forget to initialize your app with the Backendless.initApp( appId, apiKey ) call function userRegistered( user ) { console.log( "user has been registered" ); } function gotError( err ) // see more on error handling { console.log( "error message - " + err.message ); console.log( "error code - " + err.statusCode ); } var user = new Backendless.User(); user.email = "james.bond@mi6.co.uk"; user.password = "iAmWatchingU"; Backendless.UserService.register( user ).then( userRegistered ).catch( gotError );
Turning Registration Off¶
User registration can be disabled for a particular version of the application using the Backendless Console:
- Login to the console and select the application.
- Click the Users icon in the vertical icon menu on the left.
- Click User Registration.
The Registration toggle turns the registration API on or off. When the registration is turned off and a user attempts to register, the system returns error 3009
.
Email Confirmations¶
Backendless can send out an email requesting new registered users to confirm their email address. This feature can be configured in the Backendless Console:
- Log into the console and select the application.
- Click the Users icon in the vertical icon menu on the left.
- Click User Registration.
When email confirmations are turned on (the feature is disabled by default), the "email"
user property is required and must contain a value formatted as an email address. To configure the text of the email message, click the Messaging icons in the vertical icon bar in Backendless console and select the EMAILS tab. Use the User made registration template.
When email confirmations are enabled in the app, new registered users will not be able to login until they confirm their email address. For more information see the User Status section of this guide.