-
Notifications
You must be signed in to change notification settings - Fork 0
Add and fix a bunch of stuff #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
20e18a8
add demo_url
ImShyMike 02faeb2
use direct model updating
ImShyMike 7574850
better otp email
ImShyMike 0cd83af
use direct model updating (again)
ImShyMike 80693a3
fmt
ImShyMike 0cd8ac2
get hackatime projects
ImShyMike c6c14f7
fmt
ImShyMike 40ba6f3
add get user info route
ImShyMike 2c501fc
validate email before updating
ImShyMike e700a99
fmt
ImShyMike 87e2aa1
remove old TODOs
ImShyMike a6e07eb
don't return deletion date
ImShyMike 44695c0
don't include OTP in subject
ImShyMike 59263e6
use params instead of data
ImShyMike 2b7c859
oopsies
ImShyMike 6697b18
reraise exception
ImShyMike 7578985
unnecessary if check
ImShyMike ad6429f
default to none
ImShyMike b2a6601
add redis data validation
ImShyMike 6545fe5
fmt
ImShyMike File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,8 @@ | |
| HOST = "redis" if os.getenv("USING_DOCKER") == "true" else "localhost" | ||
| r = redis.Redis(password=os.getenv("REDIS_PASSWORD", ""), host=HOST) | ||
|
|
||
| with open("v1/auth/otp.html", "r", encoding='utf8') as f: | ||
| OTP_EMAIL_TEMPLATE = f.read() | ||
|
|
||
| class Permission(Enum): | ||
| """User permissions""" | ||
|
|
@@ -237,15 +239,12 @@ async def refresh_token( | |
| async def send_otp(_request: Request, otp_request: OtpClientRequest): | ||
| """Send OTP to the user's email""" | ||
| otp = secrets.SystemRandom().randrange(100000, 999999) | ||
| await r.setex(f"otp-{otp_request.email}", 300, otp) | ||
| await r.setex(f"otp-{otp_request.email}", 600, otp) | ||
| message = EmailMessage() | ||
| message["From"] = os.getenv("SMTP_EMAIL", "[email protected]") | ||
| message["To"] = otp_request.email | ||
| message["Subject"] = "Aces OTP code" | ||
| message.set_content( | ||
| f"Your OTP for Aces is {otp}! This code will expire in 5 minutes. \n" | ||
| f"Happy Hacking!\n\n- Aces Organizing Team" | ||
| ) | ||
| message["Subject"] = f"Aces OTP code: {otp}" | ||
| message.set_content(OTP_EMAIL_TEMPLATE.replace("{{OTP}}", str(otp)), subtype="html") | ||
|
|
||
| await aiosmtplib.send( | ||
| message, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f4f4f4;"> | ||
| <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #840027; padding: 50px 0px;"> | ||
| <tr> | ||
| <td align="center"> | ||
| <table width="600" cellpadding="0" cellspacing="0" style="background-color: #a50036; border-radius: 0.5rem; overflow: hidden"> | ||
| <tr> | ||
| <td style="padding: 25px 30px;"> | ||
| <p style="margin: 0 0 20px; color: #ffffff; font-size: 16px; line-height: 1.5;"> | ||
| Your one-time password is: | ||
| </p> | ||
| <div style="text-align: center; margin: 30px 0;"> | ||
| <span style="display: inline-block; background-color: #eeeeee; border-radius: 0.375rem; padding: 20px 40px; font-size: 32px; font-weight: bold; color: #333333; letter-spacing: 8px;">{{OTP}}</span> | ||
| </div> | ||
| <p style="margin: 0; color: #ffffff; font-size: 16px; line-height: 1.5;"> | ||
| This code will expire in <strong>10 minutes</strong>. | ||
| </p> | ||
| <p style="margin: 0; color: #eeeeee; font-size: 14px; line-height: 1.5;"> | ||
| If you didn't request this code, please ignore this email. | ||
| </p> | ||
| </td> | ||
| </tr> | ||
| </table> | ||
| </td> | ||
| </tr> | ||
| </table> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.