models
A module that contains models of the users package.
Classes
AuthUser
: A class that creating user model.
AuthUser
Bases: models.Model
Model for authenticated users.
Attributes:
Name | Type | Description |
---|---|---|
user_id |
models.UUIDField
|
id of the user |
email |
models.EmailField
|
the email of the user |
username |
models.CharField
|
the username of the user |
password |
models.CharField
|
the password of the user |
token |
models.CharField
|
the token of the user |
created_at |
models.DateTimeField
|
the datetime when user is created |
updated_at |
models.DateTimeField
|
the updated datatime when updating the user |
Methods
set_password(raw_password)
: A method to set user password to hash passwordcheck_password(new_password)
: A method to check if the password is correct or notset_token(email)
: A method to set user token
Source code in backend/api/users/models.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
Meta
Metaclass for AuthUser model.
Attributes:
Name | Type | Description |
---|---|---|
db_table |
str
|
the table name |
Source code in backend/api/users/models.py
35 36 37 38 39 40 41 42 |
|
check_password(new_password)
Check if the entered password is correct.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_password |
str
|
The new password entered by the user. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the password is correct, else False. |
Source code in backend/api/users/models.py
62 63 64 65 66 67 68 69 70 71 |
|
set_password(raw_password)
Set password for the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raw_password |
str
|
The raw password entered by the user. |
required |
Source code in backend/api/users/models.py
54 55 56 57 58 59 60 |
|
set_token(email)
Generate and set token for the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
email |
str
|
Email of the user. |
required |
Source code in backend/api/users/models.py
73 74 75 76 77 78 79 |
|