Sign up
POST /users
POST
/users
Will create a new user and generate a session token for the user. This endpoint is used for both email and phone sign up.
Sign Up by Phone Flow:
- Validate request.
- phoneNumber, userType and otpCode is required
- userType should be a valid one(DNT,HYG). - Validate phone should not be registered before.
- get OTP code from cache and validate it. (cache set in POST /otp)
- Validate OTP code from request should be the same as the one in cache.
- Generate mongoID and insert to DB
- Insert to user table
- Insert to device table
- Generate refresh token and insert to refresh_token table - Delete OTP code from cache
- Generate JWT access token and return to user.
- Publish events
- AUTH_USER_CREATED
- NEW_DEVICE_TOKEN
Sign Up by Email Flow:
- Validate request.
- email and password are required.
- email should be a valid email.
- Override email to lowercase.
- Validate password criteria(length should be >=8) - Validate email should not be registered before.
- Generate mongoID and insert to DB
- Insert to user table
- Insert to device table
- Generate refresh token and insert to refresh_token table - Generate JWT access token and return to user.
- Publish events
- AUTH_USER_CREATED
- NEW_DEVICE_TOKEN
Authorizations
Section titled “Authorizations ”Request Body
Section titled “Request Body ”SignUpRequest
object
email
Required if type is email
string
ivan+rdh+fl@joingotu.com id
string
65b9fc0589526f00117cd4d2 otpCode
Required if type is phone
string
22222 password
Required if type is email
string
password phoneNumber
Required if type is phone
string
+6282243350992 referralID
string
65b9fc0589526f00117cd4d2 source
string
app type
Email | phone
string
email userType
DNT | HYG | ADM
string
HYGResponses
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 messageInternal server error
object
error
string
some meaningful error message