Skip to content

Commit

Permalink
Fetch email and phone number on authentication (#8)
Browse files Browse the repository at this point in the history
* build: add .venv to gitignore list

* feat: add email and phone number to details list

* fix(.gitignore): remove blank line

* fix(pesu.py): handle missing keys for email and phone

* docs: add email and phone fields to API specs in README
  • Loading branch information
silicoflare authored Apr 17, 2024
1 parent 84303ea commit 7e751c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ github-markdown-css/
images/
*.log
README.html
README_tmp*
README_tmp*
.venv
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ profile data was requested, the response's `profile` key will store a dictionary
| `branch` | Complete name of the branch that the user is pursuing |
| `semester` | Current semester that the user is in |
| `section` | Section of the user |
| `email` | Email address of the user registered with PESU |
| `phone` | Phone number of the user registered with PESU |
| `campus_code` | The integer code of the campus (1 for RR and 2 for EC) |
| `campus` | Abbreviation of the user's campus name |

Expand Down
3 changes: 3 additions & 0 deletions app/pesu.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ def get_profile_information_from_requests(
key = "prn" if key == "pesu_id" else key
profile[key] = value

profile["email"] = soup.find("input", attrs={"id": "updateMail"}).get("value")
profile["phone"] = soup.find("input", attrs={"id": "updateContact"}).get("value")

# if username starts with PES1, then he is from RR campus, else if it is PES2, then EC campus
key = username if username else profile["pesu_id"]
if campus_code_match := re.match(r"PES(\d)", key):
Expand Down

0 comments on commit 7e751c1

Please sign in to comment.