User Sign In Block

User Sign in block is used to create API endpoint for user sign in.

NOTE: Sign-in must be used with POST method.

# How to create a User Sign In Block

Drag “User Sign In” under “Authentication Blocks” in block picker.

# How to use a User Sign In Block

Once your API endpoint is created. Go to your frontend app and send following fields: username and password where username can be username or email of the user in database. If you don't add any of the following fields endpoint will throw error.

{
    “username”: “test.username”,
    “password”: “examplepassword”,
}

On successful login you will get following response:

{
    "status": "error",
    "token": "example_token"
}

# Errors

Errors will be sent in JSON form and will have following fields: status, type, message

# Username key missing

{
    "status": "error",
    "type": "username key missing"
}

Following error will occur if username key is missing in request data.

# Password key missing

{
    "status": "error",
    "type": "password key missing"
}

Following error will occur if password key is missing in request data.

# User not found

{
    "status": "error",
    "type": "user not found"
}

Following error will occur if user with given username or email does not exists in database.

# Unauthorised access

{
    "status": "error",
    "type": "password field is empty"
}

Following error will occur if password for given user is wrong.