Skip to content
Snippets Groups Projects
Commit 68f9ded4 authored by Anton's avatar Anton
Browse files

add flask mail to requirements

parent e69e8a92
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -14,15 +14,17 @@ from flask_mail import Mail, Message ...@@ -14,15 +14,17 @@ from flask_mail import Mail, Message
app = Flask(__name__, static_url_path="") app = Flask(__name__, static_url_path="")
app.config.update(dict( app.config.update(
DEBUG = True, dict(
MAIL_SERVER = 'smtp.gmail.com', DEBUG=True,
MAIL_PORT = 587, MAIL_SERVER="smtp.gmail.com",
MAIL_USE_TLS = True, MAIL_PORT=587,
MAIL_USE_SSL = False, MAIL_USE_TLS=True,
MAIL_USERNAME = 'klasklatt3rmus1234@gmail.com', MAIL_USE_SSL=False,
MAIL_PASSWORD = 'wallwalla1', MAIL_USERNAME="klasklatt3rmus1234@gmail.com",
)) MAIL_PASSWORD="wallwalla1",
)
)
mail = Mail(app) mail = Mail(app)
app.logger.setLevel(logging.DEBUG) app.logger.setLevel(logging.DEBUG)
...@@ -138,29 +140,23 @@ def root(): ...@@ -138,29 +140,23 @@ def root():
return app.send_static_file("client.html") return app.send_static_file("client.html")
@app.route("/new-password", methods=["GET"]) @app.route("/new-password", methods=["GET"])
def new_password(): def new_password():
print("NEW PASSWORD ENDPOINT") print("NEW PASSWORD ENDPOINT")
email = request.args.get("email") email = request.args.get("email")
if not is_already_user(email):
return create_response(
success=True,
message="If you have an account with this email you will receive a new password on your email shortly.",
)
new_password = generate_token() if is_already_user(email):
hashed_pw = hash_password(new_password) new_password = generate_token()
database_helper.set_password(email, hashed_pw) hashed_pw = hash_password(new_password)
database_helper.set_password(email, hashed_pw)
msg = Message(
"New password requested", msg = Message(
sender="twidder@info.se", "New password requested",
recipients=[email], sender="twidder@info.se",
) recipients=[email],
msg.body = "Your new password is: " + new_password )
mail.send(msg) msg.body = "Your new password is: " + new_password
mail.send(msg)
return create_response( return create_response(
success=True, success=True,
......
Flask==1.1.4 Flask==1.1.4
Flask-Mail==0.9.1
gevent==21.12.0 gevent==21.12.0
gevent-websocket==0.10.1 gevent-websocket==0.10.1
gunicorn==20.1.0 gunicorn==20.1.0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment