Authentication¶
Objects¶
Object are json objects.
- Permission
name: Name of the permission to display it. code_name: the code for the permission.
- Group
id: ID of the group in database. name: Name of the group to display it. permissions: List of permission object.
- User
id: ID of the user in database. first_name: First name of the user. last_name: Last name of the user. email: email of the user.
- Access
- At login API, if the user is staffmember or admin we have such an object.
group: The group object which user is member of it. is_admin: If the user is admin then its true. is_staff: If the user is staffmember then its true.
Errors¶
If a token needs to be refreshed:
status_code: | 401 |
---|---|
response: | {"message": "Fresh token required"}
|
Invalid token:
status_code: | 422 |
---|---|
response: | {"message": "reason"}
|
Expired token:
status_code: | 401 |
---|---|
response: | {"message": "Token has expired"}
|
Revoked token:
status_code: | 401 |
---|---|
response: | {"message":"Token has been revoked"}
|
All of the listed APIs are restfull and content-type is
application/json
Registration API¶
-
class
fardel.core.auth.views.
RegistrationApi
[source]¶ URL: /api/auth/register/
-
post
()[source]¶ Required arguments: - password
Optional arguments: - first_name
- last_name
Response: { "message":"Successfully registered", "access_token":"access_token", "refresh_token":"refresh_token" }
Errors: if email or password does not provided:
status_code: 400
response: {"message":"Unvalid form submitted"}
If email already exists:
status_code: 409
response: {"message": "A user with this email already exists."}
-
Login API¶
-
class
fardel.core.auth.views.
LoginApi
[source]¶ URL: /api/auth/login/
-
post
()[source]¶ Required arguments: - password
Response: { "message":"Successfully registered", "access_token":"access_token", "refresh_token":"refresh_token", "access": AccessObject }
Errors: if email or password does not provided:
status_code: 400
response: {"message":"Unvalid form submitted"}
If email or password is not correct:
status_code: 401
response: {"message":"Username or password is not correct"}
-