Customer authentication
Register Customer account
Register a new Customer with email, password, and optional data.
This method requires the ClientAccountRegisterContext
object with a Customer’s email, password, and optional data. Omitted fields are not modified.
Depending on 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 does not require authorization.
Declared In
lib/main/modules/ClientModule.js
Related
lib/classes/models/Client/ClientAccountRegisterContext.js
Method
Synerise.Client.registerAccount(context, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
context |
ClientAccountRegisterContext |
yes | - | Object with the Customer’s email, password, and other optional data |
onSuccess |
function |
no | - | Callback function to be executed when the operation finishes successfully |
onError |
function |
no | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
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
Confirm a Client account with the confirmation token.
The The method returns the HTTP 400 status code if the account is already confirmed or 404 if the account does not exist. This method is a global operation and does not require authorization.
Declared In
lib/main/modules/ClientModule.js
Method
Synerise.Client.confirmAccount(token, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
token |
string |
yes | - | Customer’s token provided by email |
onSuccess |
function |
no | - | Callback function to be executed when the operation finishes successfully |
onError |
function |
no | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Example
Synerise.Client.confirmAccount("TOKEN", function() {
// success
}, function(error) {
// failure
});
Activate Customer account
Activate a Customer with email. This method requires the Customer’s email. This method is a global operation and does not require authorization.
Declared In
lib/main/modules/ClientModule.js
Method
Synerise.Client.activateAccount(email, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
email |
string |
yes | - | Customer’s email |
onSuccess |
function |
no | - | Callback function to be executed when the operation finishes successfully |
onError |
function |
no | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Example
Synerise.Client.activateAccount("EMAIL", function() {
// success
}, function(error) {
// failure
});
Request Customer account activation by pin
Requests a customer’s account registration process with PIN code.
Declared In
lib/main/modules/ClientModule.js
Method
Synerise.Client.requestAccountActivationByPin(email, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
string |
yes | - | Client’s email | |
onSuccess | function |
yes | - | Callback function to be executed when the operation finishes successfully |
onError | function |
yes | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Confirm Customer account activation by pin
Confirms a customer’s account registration process with PIN code.
Declared In
lib/main/modules/ClientModule.js
Method
Synerise.Client.confirmAccountActivationByPin(pinCode, email, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
pinCode | string |
yes | - | Code sent to client’s email |
string |
yes | - | Client’s email | |
onSuccess | function |
yes | - | Callback function to be executed when the operation finishes successfully |
onError | function |
yes | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Sign in a Customer
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
Method
Synerise.Client.signIn(email, password, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
email |
string |
yes | - | Customer’s email |
password |
string |
yes | - | Customer’s password |
onSuccess |
function |
no | - | Callback function to be executed when the operation finishes successfully |
onError |
function |
no | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Example
let email = "EMAIL";
let password = "PASSWORD";
Synerise.Client.signIn(email, password, function() {
// success
}, function(error) {
// failure
});
Sign in a Customer conditionally
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
Method
Synerise.Client.signInConditionally(email, password, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
email |
string |
yes | - | Customer’s email |
password |
string |
yes | - | Customer’s password |
onSuccess |
function |
no | - | Callback function to be executed when the operation finishes successfully |
onError |
function |
no | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Example
let email = "EMAIL";
let password = "PASSWORD";
Synerise.Client.signInConditionally(email, password, function(clientConditionalAuthResult) {
// success
}, function(error) {
// failure
});
Authenticate Customer by IdentityProvider
Use this method to authenticate with OAuth, Facebook, Google, Apple, or Synerise.
If an account for the Client does not exist and the identityProvider is different than SYNERISE, this request creates an account.
Declared In
lib/main/modules/ClientModule.js
Related
lib/classes/models/Client/ClientIdentityProvider.js
Method
Synerise.Client.authenticate(token, clientIdentityProvider, context, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
token |
string |
yes | - | Token retrieved from |
clientIdentityProvider |
ClientIdentityProvider | yes | - | Provider of your token |
context |
ClientAuthContext | no | - | Object which wraps around agreements, attributes and authId |
onSuccess |
function |
yes | - | Callback function to be executed when the operation finishes successfully |
onError |
function |
yes | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Example
Synerise.Client.authenticate(token, ClientIdentityProvider.Oauth, context, function() {
// success
}, function(error) {
// failure
})
Authenticate Customer conditionally by IdentityProvider
Use this method to authenticate with OAuth, Facebook, Google, Apple, or Synerise.
If the account does not exist, a new one is NOT created; the operation returns an error.
Declared In
lib/main/modules/ClientModule.js
Related
lib/classes/models/Client/ClientIdentityProvider.js
Method
Synerise.Client.authenticateConditionally(token, clientIdentityProvider, context, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
token |
string |
yes | - | Token retrieved from |
clientIdentityProvider |
ClientIdentityProvider | yes | - | Provider of your token |
context |
ClientAuthContext | no | - | Object which wraps around agreements, attributes and authId |
onSuccess |
function |
yes | - | Callback function to be executed when the operation finishes successfully |
onError |
function |
yes | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Example
Synerise.Client.authenticateConditionally(token, ClientIdentityProvider.Oauth, context, function(clientConditionalAuthResult) {
// success
}, function(error) {
// failure
})
Check if a Customer is signed in
Check if a Customer is signed in (their token is authorized).
Declared In
lib/main/modules/ClientModule.js
Method
Synerise.Client.isSignedIn()
Return Value
true
if the customer is signed in, otherwise returns false
.
Example
let isSignedIn = Synerise.Client.isSignedIn();
Sign out a Customer
Signing a Customer out clears the Customer’s JWT token.
Declared In
lib/main/modules/ClientModule.js
Method
Synerise.Client.signOut()
Return Value
There is no return value.
Example
Synerise.Client.signOut();
Authenticate Customer by OAuth with registration
Use this method to authenticate by OAuth.
Returns the HTTP 401 status code if the provided access token and/or API Key is invalid.
Declared In
lib/main/modules/ClientModule.js
Related
lib/classes/models/Client/ClientOAuthAuthenticationContext.js
Method
Synerise.Client.authenticateByOAuth(accessToken, clientOAuthContext, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
accessToken |
string |
yes | - | Token retrieved from OAuth authorization |
clientOAuthContext |
ClientOAuthAuthenticationContext |
yes | - | Object that stores authId, agreements, and attributes |
onSuccess |
function |
no | - | Callback function to be executed when the operation finishes successfully |
onError |
function |
no | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Example
Synerise.Client.authenticateByOAuth(token, context, function() {
// success
}, function(error) {
// failure
})
Authenticate Customer by OAuth without registration
Use this method to authenticate by OAuth with an already registered account.
Returns the HTTP 401 status code if the provided access token and/or API Key is invalid.
Declared In
lib/main/modules/ClientModule.js
Method
Synerise.Client.authenticateByOAuthIfRegistered(accessToken, authID, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
accessToken |
string |
yes | - | Token retrieved from OAuth authorization |
authID |
string |
no | - | Optional authenticationId to decrease UUID refresh frequency |
onSuccess |
function |
no | - | Callback function to be executed when the operation finishes successfully |
onError |
function |
no | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Example
Synerise.Client.authenticateByOAuthIfRegistered(accessToken, authID, function() {
// success
}, function(error) {
// failure
})
Authenticate Customer by Facebook with registration
Use this method to authenticate by Facebook.
Returns the HTTP 401 status code if the provided Facebook token and/or API Key is invalid.
Declared In
lib/main/modules/ClientModule.js
Related
lib/classes/models/Client/ClientFacebookAuthenticationContext.js
Method
Synerise.Client.authenticateByFacebook(facebookToken, clientFacebookAuthenticationContext, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
facebookToken |
string |
yes | - | Token retrieved from Facebook SDK |
clientFacebookAuthenticationContext |
ClientFacebookAuthenticationContext |
yes | - | Object that stores authId, agreements, and attributes |
onSuccess |
function |
no | - | Callback function to be executed when the operation finishes successfully |
onError |
function |
no | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Example
Synerise.Client.authenticateByFacebook(token, clientFacebookAuthenticationContext, function(clientConditionalAuthResult) {
// success
}, function(error) {
// failure
})
Authenticate Customer by Facebook without registration
Use this method to authenticate by Facebook.
Returns the HTTP 401 status code if there is no account associated with the provided Facebook token.
Declared In
lib/main/modules/ClientModule.js
Method
Synerise.Client.authenticateByFacebookIfRegistered(facebookToken, authID, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
facebookToken |
string |
yes | - | Token retrieved from Facebook SDK |
authID |
string |
no | - | Optional authId to decrease the number of UUID refreshes |
onSuccess |
function |
no | - | Callback function to be executed when the operation finishes successfully |
onError |
function |
no | - | Callback function to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Example
Synerise.Client.authenticateByFacebookIfRegistered(facebookToken, authID, function() {
// success
}, function(error) {
// failure
})
Authenticate Customer by Sign in with Apple with registration
Use this method to sign in with Apple Sign In.
Declared In
lib/main/modules/ClientModule.js
Related
lib/classes/models/Client/ClientAppleSignInAuthenticationContext.js
Method
Synerise.Client.authenticateByAppleSignIn(identityToken, clientAppleSignInAuthenticationContext, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
identityToken |
String |
no | - | Token retrieved from Sign In With Apple service |
context |
ClientAppleSignInAuthenticationContext |
no | - | Object with marketing agreements and optional attributes |
authID |
String |
no | - | Custom identity for authorization |
success |
Block/Closure |
no | - | Block/closure to be executed when the operation finishes successfully |
failure |
Block/Closure |
no | - | Block/closure to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.
Authenticate Customer by Sign in with Apple without registration
Use this method to sign in with Apple Sign In.
Declared In
lib/main/modules/ClientModule.js
Related
lib/classes/models/Client/ClientAppleSignInAuthenticationContext.js
Method
Synerise.Client.authenticateByAppleSignInIfRegistered(identityToken, onSuccess, onError)
Parameters
Parameter | Type | Mandatory | Default | Description |
---|---|---|---|---|
identityToken |
String |
no | - | Token retrieved from Sign In With Apple service |
authID |
String |
no | - | Custom identity for authorization |
success |
Block/Closure |
no | - | Block/closure to be executed when the operation finishes successfully |
failure |
Block/Closure |
no | - | Block/closure to be executed when the operation finishes unsuccessfully |
Return Value
There is no return value.