Aller au contenu principal

auth

Permet d'authentifier les utilisateurs.

Description

Cette méthode effectue l'autorisation de l'utilisateur. Elle renvoie une Promise qui se résout en un objet IAuthEntity.

AuthProvider.auth(

marker, body

);

Schéma des paramètres

Schéma

marker(obligatoire): string
L'identifiant textuel du fournisseur d'autorisation
exemple: "email"

body(obligatoire): IAuthPostBody
Les objets contiennent des informations d'authentification
exemple:

{
"authData": [
{
"marker": "login",
"value": "example@oneentry.cloud"
},
{
"marker": "password",
"value": "12345"
}
]
}

body.authData any[]
Données d'autorisation prises du formulaire attaché au fournisseur d'autorisation
exemple: ""

[
{
"marker": "login",
"value": "example@oneentry.cloud"
},
{
"marker": "password",
"value": "12345"
}
]

body.authData[index].marker string
Marqueur de l'attribut de connexion du formulaire d'inscription
exemple: "example@oneentry.cloud"

body.authData[index].value string
Valeur de l'attribut de connexion du formulaire d'inscription
exemple: "12345"

Exemples

Exemple minimal

const body = {
"authData": [
{
"marker": "login",
},
{
"marker": "password",
"value":"12345"
}
],
};

const response = await AuthProvider.auth('email', body);

Exemple de réponse

{
"userIdentifier": "test@test.ru",
"authProviderIdentifier": "email",
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6OCwiYXV0aFByb3ZpZGVySWRlbnRpZmllciI6ImVtYWlsIiwidXNlcklkZW50aWZpZXIiOiJ0ZXN0QHRlc3QucnUiLCJpYXQiOjE3NTkyNjQzNjEsImV4cCI6MTc1OTMwMDM2MX0.rEa9MeA540H7NYUngnlz6zPUM9G-VqoFbFkGrqy8buw",
"refreshToken": "1759264361355-493c46b6-0a99-4871-9808-9a5524eef515"
}

Schéma de réponse

Schéma: IAuthEntity

userIdentifier: string
L'identifiant unique de l'utilisateur.
exemple: "user12345"

authProviderIdentifier: string
L'identifiant du fournisseur d'authentification.
exemple: "email"

accessToken: string
Le jeton d'accès pour la session utilisateur.
exemple: "abcdef123456"

refreshToken: string
Le jeton de rafraîchissement pour renouveler le jeton d'accès.
exemple: "ghijkl789012"