Login with phone and otp code
POST /sessions/phone
POST
/sessions/phone
Will generate a session token for the user using phone and otp code
Flow:
- Validate request.
- phoneNumber and otpCode are required.
- Validate phoneNumber should be a valid phone.
- Device info are coming from headers, and they’re optional. - Validate user with the phoneNumber should exists
- Validate user status is not blocked or paused
- Get OTP code from cache. (cache set in POST /otp)
- Validate OTP code from request should be the same as the one in cache.
- Insert to device table
- Generate refresh token and insert to refresh_token table
- Update user’s last_active_at
- Delete OTP code from cache.
- Generate JWT access token and return to user.
Authorizations
Section titled “Authorizations ”Request Body
Section titled “Request Body ”LoginPhoneRequest
object
otpCode
string
222222 phoneNumber
string
+6282243350992Responses
Section titled “ Responses ”OK
object
data
object
accessToken
string
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhdXRoLXNlcnZpY2UiLCJzdWIiOiI2NWI4YTE2MjYzNTEyNjAwMTI3YTQxYTQiLCJleHAiOjE3MzkyNzYwNzMsIm5iZiI6MTczOTI3NTE3MywiaWF0IjoxNzM5Mjc1MTczLCJqdGkiOiJjdWxqbjlhc3A1anJmam83NWdiZyIsImlkIjoiNjViOGExNjI2MzUxMjYwMDEyN2E0MWE0IiwidXNlclR5cGUiOiJETlQiLCJpc0FkbWluIjp0cnVlLCJkZXZpY2VJZCI6MzE4M30.ZuzROGxJ1pq_veRe93Z8bfS5YTzmAp5_wrzTUmvLzk8 expiresIn
integer
900 refreshToken
string
culjn9asp5jrfjo75gc0 tokenType
string
BearerBad request
object
error
string
some meaningful error messageUnauthorized
object
error
string
some meaningful error messageForbidden
object
error
string
some meaningful error messageNot found
object
error
string
some meaningful error messageInternal server error
object
error
string
some meaningful error message