Resend
This resend
endpoint is simply to re-send the access code to the customer if it was not received correctly. The customer is given 30 seconds to enter the received access code, so if there was an issue with receiving the access code, another new code may be re-sent.
:::tip
The resend endpoint has been implemented in the Login Web Component, and It's all setup to save developer's time and effort.
:::
Payload
Response
Usage
The resend()
method passes a request for a new access code to the customer.
The method may pass the phone number and country code to where the new access code should be sent.
salla.auth.resend({
type: 'mobile',
phone: '555555555',
country_code: 'SA'
}).then((response) => {
/* add your code here */
});
On the other hand, when using an email as a login type, the developer can receive the data using the example below and redirect the user accordingly.
salla.auth.resend({
type: 'email',
email: '[email protected]'
}).then((response) => {
/* add your code here */
});
Events
This endpoint may trigger two events, the onCodeSent and onCodeNotSent events.
onCodeSent
This event is triggered when the new access code generation has been done without having any errors back from the backend.
salla.event.auth.onCodeSent((response) => {
console.log(response)
});
onCodeNotSent
This event is triggered when the new access code generation has failed, and no new access code has been sent to the customer.
salla.event.auth.onCodeNotSent((errorMessage) => {
console.log(errorMessage)
});