UPDATE: Updated VideoPage UI
UPDATE: Added response to successful password reset redirect to homepage
This commit is contained in:
@@ -11,7 +11,8 @@ google = None
|
||||
|
||||
from os import getenv
|
||||
load_dotenv()
|
||||
url = getenv("VITE_API_URL")
|
||||
url_api = getenv("VITE_API_URL")
|
||||
url = getenv("HOMEPAGE_URL")
|
||||
|
||||
|
||||
def init_oauth(app):
|
||||
@@ -27,7 +28,7 @@ def init_oauth(app):
|
||||
api_base_url='https://www.googleapis.com/oauth2/v1/',
|
||||
userinfo_endpoint='https://openidconnect.googleapis.com/v1/userinfo',
|
||||
server_metadata_url='https://accounts.google.com/.well-known/openid-configuration',
|
||||
redirect_uri=f"{url}/api/google_auth"
|
||||
redirect_uri=f"{url_api}/google_auth"
|
||||
)
|
||||
|
||||
@oauth_bp.route('/login/google')
|
||||
@@ -40,7 +41,7 @@ def login_google():
|
||||
session["origin"] = request.args.get("next")
|
||||
|
||||
return google.authorize_redirect(
|
||||
f'{url}/api/google_auth',
|
||||
f'{url_api}/google_auth',
|
||||
nonce=session['nonce']
|
||||
)
|
||||
|
||||
|
||||
@@ -131,11 +131,7 @@ def user_reset_password(token, new_password):
|
||||
r.delete(token)
|
||||
|
||||
email = verify_token(token[:-5], salt_value)
|
||||
|
||||
if email:
|
||||
response = reset_password(new_password, email)
|
||||
if response:
|
||||
return 200
|
||||
else:
|
||||
return jsonify({"error": "Failed to reset password"}), 500
|
||||
reset_password(new_password, email)
|
||||
return jsonify({"message": "Password reset successful"}), 200
|
||||
return jsonify({"error": "Invalid token"}), 400
|
||||
@@ -31,7 +31,7 @@ def verify_token(token: str, salt_value) -> Optional[str]:
|
||||
print("Token is invalid", flush=True)
|
||||
return None
|
||||
|
||||
def reset_password(new_password: str, email: str) -> bool:
|
||||
def reset_password(new_password: str, email: str):
|
||||
"""
|
||||
Given email and new password reset the password for a given user
|
||||
"""
|
||||
@@ -41,5 +41,3 @@ def reset_password(new_password: str, email: str) -> bool:
|
||||
SET password = ?
|
||||
WHERE email = ?
|
||||
""", (generate_password_hash(new_password), email))
|
||||
|
||||
return True
|
||||
@@ -12,6 +12,9 @@ r = redis.from_url(redis_url, decode_responses=True)
|
||||
|
||||
load_dotenv()
|
||||
|
||||
url = getenv("HOMEPAGE_URL")
|
||||
|
||||
|
||||
def send_email(email, func) -> None:
|
||||
"""
|
||||
Send a verification email to the user.
|
||||
@@ -53,7 +56,6 @@ def forgot_password_body(email) -> str:
|
||||
|
||||
token = generate_token(email, salt)
|
||||
token += "R3sET"
|
||||
url = getenv("VITE_API_URL")
|
||||
r.setex(token, 3600, salt)
|
||||
|
||||
full_url = url + "/reset_password/" + token
|
||||
@@ -92,7 +94,6 @@ def confirm_account_creation_body(email) -> str:
|
||||
|
||||
token = generate_token(email, salt)
|
||||
token += "CrEaTe"
|
||||
url = getenv("VITE_API_URL")
|
||||
r.setex(token, 3600, salt)
|
||||
|
||||
full_url = url + "/confirm_account_creation/" + token
|
||||
|
||||
Reference in New Issue
Block a user