common.services.cookie
get_cookie(user)
async
Find cookie in database. if not found or invalid, logins to get a new cookie str and stores it in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user
|
LMSUser
|
LMS User instance |
required |
Returns:
Type | Description |
---|---|
LMSCookie
|
An LMSCookie |
Source code in src/common/services/cookie.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
is_cookie_valid(cookie)
async
Send request to /members/home to see if cookie has expired. If response is 302, request is being redirected to the login page. So, the cookie was expired (or invalid). If not, it's reached /members/home.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cookie
|
LMSCookie
|
An LMSCookie |
required |
Returns:
Type | Description |
---|---|
bool
|
True if we're not redirected to another page (login), |
bool
|
False if redirected. |
Source code in src/common/services/cookie.py
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 |
|
login(user)
async
Login to LMS. BASE_URL
and LOGIN_SUFFIX_URL
are taken from
constants.py. If status is 302, request is being redirected
to the home page, so the login is successful. If not, session
is still at the login page, so it was not successful.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user
|
LMSUser
|
LMSUser instance |
required |
Returns:
Type | Description |
---|---|
LMSCookie
|
An LMSCookie |
Source code in src/common/services/cookie.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|