Customer authentication
Set Client State listener
This method sets callbacks for a customer’s state changes.
Declared In:
lib/main/modules/ClientModule.js
Related To:
ClientStateChangeListener
Class:
ClientModule
Declaration:
public setClientStateChangeListener(listener: IClientStateChangeListener)
Discussion:
Learn more about the methods and the purpose of this listener here.
Register customer account
This method registers a new customer with an email, password, and optional data.
This method requires the context object with a customer’s email, password, and optional data. Omitted fields are not modified.
Depending on the backend configuration, the account may require activation. For details, see customer registration.
Do not allow signing in again (or signing up) when a customer is already signed in. Sign the customer out first.
Do not create multiple instances nor call this method multiple times before execution.
This method is a global operation and doesn’t require customer authentication.
SAUTH_REGISTER_CLIENT_CREATE
permission from the Client group.Declared In:
lib/main/modules/ClientModule.js
Related To:
ClientAccountRegisterContext
Class:
ClientModule
Declaration:
public registerAccount(context: ClientAccountRegisterContext, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
context | ClientAccountRegisterContext | yes | - | Object with the customer’s email, password, and other optional data |
onSuccess | Function | no | - | Function to be executed when the operation is completed successfully |
onError | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
let email = "EMAIL";
let password = "PASSWORD";
let context = new ClientAccountRegisterContext(email, password);
context.phone = '123456789';
context.customId = '000111';
context.firstName = 'John';
context.lastName = 'Rise';
context.sex = ClientSex.Male;
context.company = 'Synerise';
context.address = 'Marszałkowska';
context.city = 'Warszawa';
context.province = 'Mazowieckie';
context.zipCode = '00-000';
context.countryCode = 'PL';
context.agreements = new ClientAgreements({
email: true,
sms: false,
push: true,
bluetooth: false,
rfid: true,
wifi: false
});
context.attributes = { ATTRIBUTE_1: 'ATTRIBUTE_1' }
context.tags = ['TAG_1', 'TAG_2']
Synerise.Client.registerAccount(context, function() {
// success
}, function(error) {
// failure
});
Confirm customer account
This method confirms a customer account with the confirmation token.
This method is a global operation and doesn’t require customer authentication.
SAUTH_CONFIRMATION_CLIENT_CREATE
permission from the Client group.Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public confirmAccount(token: string, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
token | string | yes | - | Customer’s token provided by email |
onSuccess | Function | no | - | Function to be executed when the operation is completed successfully |
onError | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
Synerise.Client.confirmAccount("TOKEN", function() {
// success
}, function(error) {
// failure
});
Activate customer account
This method requests sending an email with a URL that confirms the registration and activates the account.
This method is a global operation and doesn’t require customer authentication.
SAUTH_CONFIRMATION_CLIENT_CREATE
permission from the Client group.Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public activateAccount(email: string, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
string | yes | - | Customer’s email | |
onSuccess | Function | no | - | Function to be executed when the operation is completed successfully |
onError | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
Synerise.Client.activateAccount("EMAIL", function() {
// success
}, function(error) {
// failure
});
Request customer account activation by pin
This method requests a customer’s account registration process with the PIN code.
This method is a global operation and doesn’t require customer authentication.
SAUTH_PIN_CODE_RESEND_CLIENT_CREATE
permission from the Client group.Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public requestAccountActivationByPin(email: string, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
string | yes | - | Customer’s email | |
onSuccess | Function | yes | - | Function to be executed when the operation is completed successfully |
onError | Function | yes | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Confirm customer account activation by pin
This method confirms a customer’s account registration process with the PIN code.
This method is a global operation and doesn’t require customer authentication.
SAUTH_PIN_CODE_RESEND_CLIENT_CREATE
permission from the Client group.Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public confirmAccountActivationByPin(pinCode: string, email: string, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
pinCode | string | yes | - | Code sent to a customer’s email |
string | yes | - | Customer’s email | |
onSuccess | Function | yes | - | Function to be executed when the operation is completed successfully |
onError | Function | yes | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Sign in a customer
This method signs a customer in to obtain a JSON Web Token (JWT) which can be used in subsequent requests.
The SDK will refresh the token before each call if it is about to expire (but not expired).
Do NOT allow signing in again (or signing up) when a customer is already signed in. First, sign the customer out.
Do NOT create multiple instances nor call this method multiple times before execution.
Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public signIn(email: string, password: string, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
string | yes | - | Customer’s email | |
password | string | yes | - | Customer’s password |
onSuccess | Function | no | - | Function to be executed when the operation is completed successfully |
onError | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
let email = "EMAIL";
let password = "PASSWORD";
Synerise.Client.signIn(email, password, function() {
// success
}, function(error) {
// failure
});
Sign in a customer conditionally
This method signs a customer in to obtain a JSON Web Token (JWT) which can be used in subsequent requests.
The SDK will refresh the token before each call if it is about to expire (but not expired).
Do NOT allow signing in again (or signing up) when a customer is already signed in. First, sign the customer out.
Do NOT create multiple instances nor call this method multiple times before execution.
Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public signInConditionally(email: string, password: string, onSuccess: (authResult: ClientConditionalAuthResult) => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
string | yes | - | Customer’s email | |
password | string | yes | - | Customer’s password |
onSuccess | Function | no | - | Function to be executed when the operation is completed successfully |
onError | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
let email = "EMAIL";
let password = "PASSWORD";
Synerise.Client.signInConditionally(email, password, function(clientConditionalAuthResult) {
// success
}, function(error) {
// failure
});
Authenticate customer by IdentityProvider
This method authenticates a customer with OAuth, Facebook, Google, Apple, or Synerise.
If an account for the customer does not exist and the identity provider is different than Synerise, this request creates an account.
Declared In:
lib/main/modules/ClientModule.js
Related To:
ClientAuthContext
ClientIdentityProvider
Class:
ClientModule
Declaration:
public authenticate(token: string, provider: ClientIdentityProvider, context: ClientAuthContext, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
token | string | yes | - | Token retrieved from provider |
clientIdentityProvider | ClientIdentityProvider | yes | - | Provider of your token |
context | ClientAuthContext | yes | - | Object which wraps around agreements, attributes and authId |
onSuccess | Function | yes | - | Function to be executed when the operation is completed successfully |
onError | Function | yes | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
Synerise.Client.authenticate(token, ClientIdentityProvider.Oauth, context, function() {
// success
}, function(error) {
// failure
})
Authenticate customer conditionally by IdentityProvider
This method authenticates a customer with OAuth, Facebook, Google, Apple, or Synerise.
Declared In:
lib/main/modules/ClientModule.js
Related To:
ClientAuthContext
ClientIdentityProvider
Class:
ClientModule
Declaration:
public authenticateConditionally(token: string, provider: ClientIdentityProvider, context: ClientAuthContext, onSuccess: (authResult: ClientConditionalAuthResult) => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
token | string | yes | - | Token retrieved from provider |
clientIdentityProvider | ClientIdentityProvider | yes | - | Provider of your token |
context | ClientAuthContext | no | - | Object which contains agreements, attributes, and identifier of authorization |
onSuccess | Function | yes | - | Function to be executed when the operation is completed successfully |
onError | Function | yes | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
Synerise.Client.authenticateConditionally(token, ClientIdentityProvider.Oauth, context, function(clientConditionalAuthResult) {
// success
}, function(error) {
// failure
})
Authenticate customer via Simple Authentication
This method authenticates a customer with Simple Authentication.
SAUTH_SIMPLE_AUTH_CREATE
from the Auth group.Declared In:
lib/main/modules/ClientModule.js
Related To:
ClientSimpleAuthenticationData
Class:
ClientModule
Declaration:
public simpleAuthentication(data: ClientSimpleAuthenticationData, authID: string, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
data | ClientSimpleAuthenticationData | yes | - | Object which contains customer data |
authID | string | yes | - | Required identifier of authorization |
onSuccess | Function | yes | - | Function to be executed when the operation is completed successfully |
onError | Function | yes | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
let data: ClientSimpleAuthenticationData = new ClientSimpleAuthenticationData();
context.email = "EMAIL";
context.firstName = "FIRST_NAME";
let authID: String = "AUTH_ID"
Synerise.Client.simpleAuthentication(data, authID, function() {
// success
}, function(error) {
// failure
})
Check if a customer is signed in (via RaaS, OAuth, Facebook, Apple)
This method checks if a customer is signed in (via RaaS, OAuth, Facebook, Apple).
Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public isSignedIn(): boolean
Return Value:
true if the customer is signed in, otherwise returns false.
Example:
let isSignedIn = Synerise.Client.isSignedIn();
Check if a customer is signed in (via Simple Authentication)
This method checks if a customer is signed in (via Simple Authentication).
Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public isSignedInViaSimpleAuthentication(): boolean
Return Value:
true if the customer is signed in (via Simple Authentication), otherwise returns false.
Example:
let isSignedIn = Synerise.Client.isSignedInViaSimpleAuthentication();
Sign out a customer
This method signs out a customer out.
Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public signOut()
Return Value:
No value is returned.
Example:
Synerise.Client.signOut();
Sign out customer with mode or from all devices
This method signs out a customer out with a chosen mode and Determines if the method should sign out all devices.
Available modes:
.signOut
mode signs out the customer..signOutWithSessionDestroy
mode signs out the customer and additionally, clears the anonymous session and regenerates the customer UUID.
The fromAllDevices
parameter determines whether the method should notify the backend to sign out all devices.
IMPORTANT: It is an asynchronous method.
Declared In:
lib/main/modules/ClientModule.js
Related To:
ClientSignOutMode
Class:
ClientModule
Declaration:
public signOutWithMode(mode: ClientSignOutMode, fromAllDevices: boolean, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
mode | ClientSignOutMode | yes | - | Mode of signing out |
fromAllDevices | Bool | yes | - | Determines if the method should sign out all devices |
Return Value:
No value is returned.
Example:
Synerise.Client.signOutWithMode(
ClientSignOutMode.SignOutWithSessionDestroy,
true,
() => {
this.setState({
isLoading: false,
isSignedIn: true,
})
},
(error) => {
this.setState({
isLoading: false,
isSignedIn: false,
})
console.log('ERROR: ' + error.message);
}
)
Deprecated methods
Authenticate customer by OAuth with registration
This method authenticates a customer with OAuth.
If an account for the customer does not exist, this request creates an account.
Declared In:
lib/main/modules/ClientModule.js
Related To:
ClientOAuthAuthenticationContext
Class:
ClientModule
Declaration:
public authenticateByOAuth(accessToken: string, context: ClientOAuthAuthenticationContext, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
accessToken | string | yes | - | OAuth Access Token |
clientOAuthContext | ClientOAuthAuthenticationContext | yes | - | Object which contains agreements, attributes, and identifier of authorization |
onSuccess | Function | no | - | Function to be executed when the operation is completed successfully |
onError | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
Synerise.Client.authenticateByOAuth(token, context, function() {
// success
}, function(error) {
// failure
})
Authenticate customer by OAuth without registration
This method authenticates a customer with OAuth.
Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public authenticateByOAuthIfRegistered(accessToken: string, authID: string | null, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
accessToken | string | yes | - | OAuth Access Token |
authID | string | no | null | Optional identifier of authorization |
onSuccess | Function | no | - | Function to be executed when the operation is completed successfully |
onError | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
Synerise.Client.authenticateByOAuthIfRegistered(accessToken, authID, function() {
// success
}, function(error) {
// failure
})
Authenticate customer by Facebook with registration
This method authenticates a customer with Facebook.
If an account for the customer does not exist, this request creates an account.
Declared In:
lib/main/modules/ClientModule.js
Related To:
ClientFacebookAuthenticationContext
Class:
ClientModule
Declaration:
public authenticateByFacebook(facebookToken: string, context: ClientFacebookAuthenticationContext, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
facebookToken | string | yes | - | Facebook Access Token |
clientFacebookAuthenticationContext | ClientFacebookAuthenticationContext | yes | - | Object which contains agreements, attributes, and identifier of authorization |
onSuccess | Function | no | - | Function to be executed when the operation is completed successfully |
onError | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
Synerise.Client.authenticateByFacebook(token, clientFacebookAuthenticationContext, function(clientConditionalAuthResult) {
// success
}, function(error) {
// failure
})
Authenticate customer by Facebook without registration
This method authenticates a customer with Facebook.
Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public authenticateByFacebookIfRegistered(facebookToken: string, authID: string | null, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
facebookToken | string | yes | - | Facebook Access Token |
authID | string | no | null | Optional identifier of authorization |
onSuccess | Function | no | - | Function to be executed when the operation is completed successfully |
onError | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
Synerise.Client.authenticateByFacebookIfRegistered(facebookToken, authID, function() {
// success
}, function(error) {
// failure
})
Authenticate customer by Sign in with Apple with registration
This method authenticates a customer with Sign In With Apple.
If an account for the customer does not exist, this request creates an account.
Declared In:
lib/main/modules/ClientModule.js
Related To:
ClientAppleSignInAuthenticationContext
Class:
ClientModule
Declaration:
public authenticateByAppleSignIn(identityToken: string, context: ClientAppleSignInAuthenticationContext, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
identityToken | string | yes | - | Apple Identity Token |
context | ClientAppleSignInAuthenticationContext | yes | - | Object which contains agreements, attributes, and identifier of authorization |
success | Function | no | - | Function to be executed when the operation is completed successfully |
failure | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Authenticate customer by Sign in with Apple without registration
This method authenticates a customer with Sign In With Apple.
Declared In:
lib/main/modules/ClientModule.js
Class:
ClientModule
Declaration:
public authenticateByAppleSignInIfRegistered(identityToken: string, authID: string, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
identityToken | string | yes | - | Apple Identity Token |
authID | string | no | null | Optional identifier of authorization |
success | Function | no | - | Function to be executed when the operation is completed successfully |
failure | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.