Login API
Endpoint
POST /auth/loginPayload
User can login either with their Username or Email. The key property for both cases will be the same; email
1
2
3
4
5
6
{
"email": "example@domain.com", // Or it can be a username like "user_123". In both cases the field should be the same as "email".
"password": "P@$$w0rd",
"register_provider": "urbanfits", // and if signing in with google then provide "google".
"remember_me": true // boolean: the session will be extended upto 30 days if 'true', defaults to 7 days.
}Response
The response can be of 2 types which depends on a condition. The condition is that if the user have 2FA enabled or disabled. Which can result on 2 different possible responses:
- 2FA Enabled: If the user have 2FA enabled, the API will return a
redirect_urlin response which is for the web to easily redirect user to the Verify TOTP page but in Mobile Development, it should be taken care of by manually detecting if theredirect_urlexists then redirect the user. It is further explained in Verify TOTP API documentation. - 2FA Disabled: In case of disabled 2FA, the API will follow the below mentioned response and will directly login the user.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
"success": true,
"msg": "You are Logged in successfully !",
"user": {
"_id": "65ddb7496a09ca290bec88b2",
"username": "user_123",
"register_provider": "urbanfits",
"image": "/website-copyrights/default-pfp.webp ",
"phone_prefix": "+971",
"phone_number": "31643454835",
"email": "example@domain.com",
"two_fa_enabled": false,
"role": "customer",
"is_active": true,
"uf_wallet": {
"card_number": "70517090291921247656",
"bar_code": "/uf-wallet-barcodes/70517090291921247656",
"last_spin_reward": 200,
"last_uf_spin": "2024-05-09T23:59:59.000Z",
"next_uf_spin": "2024-05-11T00:00:00.000Z"
},
"last_checkin": "2024-05-21T23:59:59.999Z",
"timezone": "Asia/Dubai",
"user_agent": "eyJhbGciOiJIUzI1NiJ9.UG9zdG1hblJ1bnRpbWUvNy4zNy4z.lYd97Uv60STIestaaO3UO_aiP7G10yEmi_XG22KbOPo",
"purchases": 7,
"createdAt": "2024-02-27T00:00:00.000Z",
"updatedAt": "2024-06-06T12:04:37.382Z",
"__v": 0,
"firstname": "John",
"gender": "male",
"lastname": "Doe",
"title": "Mr."
}
}