-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added sending of an email with a token to recover an account
- Loading branch information
1 parent
2c82f05
commit dc35748
Showing
9 changed files
with
96 additions
and
36 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 |
---|---|---|
|
@@ -29,11 +29,13 @@ | |
# slow database query threshold (in seconds) | ||
DATABASE_QUERY_TIMEOUT = 0.5 | ||
|
||
MAIL_SERVER = 'localhost' | ||
# Notification | ||
MAIL_SERVER = "localhost" | ||
MAIL_PORT = 25 | ||
MAIL_USE_TLS = False | ||
MAIL_USE_SSL = False | ||
MAIL_DEBUG = DEBUG | ||
MAIL_USERNAME = None | ||
MAIL_PASSWORD = None | ||
MAIL_DEFAULT_SENDER = ADMIN_EMAIL | ||
MAIL_DEFAULT_SENDER = "[email protected]" | ||
TOKEN_VALIDITY_PERIOD = 3600 |
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 |
---|---|---|
|
@@ -27,11 +27,13 @@ ADMIN_EMAIL = '[email protected]' | |
|
||
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 | ||
|
||
MAIL_SERVER = 'localhost' | ||
# Notification | ||
MAIL_SERVER = "localhost" | ||
MAIL_PORT = 25 | ||
MAIL_USE_TLS = False | ||
MAIL_USE_SSL = False | ||
MAIL_DEBUG = DEBUG | ||
MAIL_USERNAME = None | ||
MAIL_PASSWORD = None | ||
MAIL_DEFAULT_SENDER = ADMIN_EMAIL | ||
MAIL_DEFAULT_SENDER = "[email protected]" | ||
TOKEN_VALIDITY_PERIOD = 3600 |
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
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
Dear {{ user.login }}, | ||
|
||
Your or someone else asked for account recovery. | ||
|
||
If it is really you click on the following link in order to confirm it: | ||
{{ instance_url }}/user/recover_account/{{ token }} | ||
|
||
The link expires at {{ expire_time.strftime('%Y-%m-%d %H:%M') }}. | ||
|
||
See you, |
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
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
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 mosp.bootstrap import application | ||
|
||
|
||
def generate_confirmation_token(login): | ||
serializer = URLSafeTimedSerializer(application.config["SECRET_KEY"]) | ||
return serializer.dumps(login, salt=application.config["SECURITY_PASSWORD_SALT"]) | ||
|
||
|
||
def confirm_token(token): | ||
serializer = URLSafeTimedSerializer(application.config["SECRET_KEY"]) | ||
try: | ||
login = serializer.loads( | ||
token, | ||
salt=application.config["SECURITY_PASSWORD_SALT"], | ||
max_age=application.config["TOKEN_VALIDITY_PERIOD"], | ||
) | ||
except: | ||
return False | ||
return login |
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