-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e399a1
commit b6f3cd1
Showing
4 changed files
with
69 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
<b>Welcome! Thanks for signing up. Please follow this link to activate your account:</b> | ||
<p><a href="{{ confirm_url }}">{{ confirm_url }}</a></p> | ||
<b>Cheers!</b> |
This file contains 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,13 @@ | ||
from flask_mail import Message | ||
|
||
from app import app | ||
from extentions import mail | ||
|
||
|
||
def send_email(to, subject, template): | ||
msg = Message( | ||
subject=subject, | ||
recipients=[to], | ||
html=template | ||
) | ||
mail.send(msg) |
This file contains 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,21 @@ | ||
from itsdangerous import URLSafeTimedSerializer | ||
|
||
from app import app | ||
|
||
|
||
def generate_confirmation_token(email): | ||
serializer = URLSafeTimedSerializer(app.config['SECRET_KEY']) | ||
return serializer.dumps(email, salt=app.config['SECURITY_PASSWORD_SALT']) | ||
|
||
|
||
def confirm_token(token, expiration=3600): | ||
serializer = URLSafeTimedSerializer(app.config['SECRET_KEY']) | ||
try: | ||
email = serializer.loads( | ||
token, | ||
salt=app.config['SECURITY_PASSWORD_SALT'], | ||
max_age=expiration | ||
) | ||
except: | ||
return False | ||
return email |
This file contains 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