models
User
Bases: Model
, UserMixin
User model for authentication and user management.
Source code in src\downtime_panda\blueprints\user\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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
create_token()
email_exists(email)
classmethod
Check if an email already exists in the database.
get_by_email(email)
classmethod
get_by_id(user_id)
classmethod
get_by_token(token)
classmethod
Validate an API token and return the associated user if valid.
Source code in src\downtime_panda\blueprints\user\models.py
get_by_username(username)
classmethod
register(username, email, password)
classmethod
Add a new user to the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username
|
str
|
Username of the user |
required |
email
|
str
|
Email of the user |
required |
password
|
str
|
Password of the user |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the username or email already exists in the database |
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
The created user instance |
Source code in src\downtime_panda\blueprints\user\models.py
revoke_token(token_id)
Revoke an API token for the user.
Source code in src\downtime_panda\blueprints\user\models.py
subscribe_to_service(service)
username_exists(username)
classmethod
Check if a username already exists in the database.
verify_password(password)
Verify the provided password against the stored hash, and rehash if necessary.