Registering Users

Registering Users

There are two ways to register, or sign up, a user with Telerik Platform. The first involves creating a user account in the own User Management facility of Telerik Platform. The second utilizes one of the supported third-party OAuth 2.0 providers such as Facebook, Google, and Microsoft Account.

Register with Telerik Platform User Management

Users registered directly with Telerik Platform User Management rely on Telerik Platform for authentication services. This is why they need to always be registered with the Username and Password properties. See Usernames and Passwords to learn about best practices for working with them. All other user account properties are optional.

As it is shown in the example, you will often have custom properties (DisplayName, AvatarImage) along with the required.

By default, anonymous users can register (create) users. See Introduction to Access Control to learn how to change the default permissions.

The user will be registered with the default role for the application.

Although you can set a role other than the default in your request, it will not take effect unless you use Master Key authentication. Using Master Key authentication is not recommended because you expose your application's master key which is a security risk. Instead, create the user account with the default role and then set the role that you want using the Telerik Platform portal.

You can register a user with the following SDK method:

The method takes five arguments. If you do not want to specify optional fields with the third argument, pass null or an empty object.

var el = new Everlive('your-app-id');

var username = 'jsmith';
var password = '111111';
var attrs = {
    Email: 'john.smith@telerik.com',
    DisplayName: 'John Smith'
};

el.Users.register(username,
    password,
    attrs,
    function(data) {
        alert(JSON.stringify(data));
    },
    function(error) {
        alert(JSON.stringify(error));
    });

After registering a user, the server will return the Id of the registered user along with its CreatedAt date on the server.

Register with an OAuth Provider

When you want to create a user account without asking for username and password, you can utilize the Telerik Platform OAuth integration. More information abou utilizing this feature can be found in Social Login.

Secret Question and Answer

Users regularly forget their password. To allow them to recover their account, you can use the secret question and answer mechanism supported by Telerik Platform. It works by providing a secret question and a secret answer fields when registering the user:

var el = new Everlive('your-app-id');

var username = 'jsmith';
var password = '111111';
var attrs = {
    Email: 'john.smith@telerik.com',
    DisplayName: 'John Smith',
    SecretQuestionId : 1,
    SecretAnswer: "dog"
};

el.Users.register(username,
    password,
    attrs,
    function(data) {
        alert(JSON.stringify(data));
    },
    function(error) {
        alert(JSON.stringify(error));
    });

If those fields are present, they can be used for resetting the password for the account as explained in Recovering User Accounts.

Note that the SecretQuestionId field only carries a numerical secret question ID. It is up to you as a developer to decide where and how to match the ID to a secret question text so you can show it to the user when necessary.

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.