BUGFIX: Google OAuth accounts password now cannot be reset
This commit is contained in:
@@ -5,7 +5,6 @@ import DynamicPageContent from "../components/Layout/DynamicPageContent";
|
|||||||
import { useFollow } from "../hooks/useFollow";
|
import { useFollow } from "../hooks/useFollow";
|
||||||
import FollowUserButton from "../components/Input/FollowUserButton";
|
import FollowUserButton from "../components/Input/FollowUserButton";
|
||||||
import FollowButton from "../components/Input/FollowButton";
|
import FollowButton from "../components/Input/FollowButton";
|
||||||
import Footer from "../components/Layout/Footer";
|
|
||||||
|
|
||||||
interface Streamer {
|
interface Streamer {
|
||||||
user_id: number;
|
user_id: number;
|
||||||
|
|||||||
@@ -196,10 +196,12 @@ def user_forgot_password(email):
|
|||||||
Initializes the function to handle password reset
|
Initializes the function to handle password reset
|
||||||
"""
|
"""
|
||||||
exists = email_exists(email)
|
exists = email_exists(email)
|
||||||
if(exists):
|
password = has_password(email)
|
||||||
|
# Checks if password exists and is not a Google OAuth account
|
||||||
|
if(exists and password):
|
||||||
send_email(email, lambda: forgot_password_body(email))
|
send_email(email, lambda: forgot_password_body(email))
|
||||||
return email
|
return email
|
||||||
return jsonify({"error":"email not found"}), 404
|
return jsonify({"error":"Invalid email or not found"}), 404
|
||||||
|
|
||||||
@user_bp.route("/send_newsletter/<string:email>", methods=["POST"])
|
@user_bp.route("/send_newsletter/<string:email>", methods=["POST"])
|
||||||
def send_newsletter(email):
|
def send_newsletter(email):
|
||||||
|
|||||||
@@ -38,6 +38,18 @@ def update_bio(user_id: int, bio: str):
|
|||||||
WHERE user_id = ?
|
WHERE user_id = ?
|
||||||
""", (bio, user_id))
|
""", (bio, user_id))
|
||||||
|
|
||||||
|
def has_password(email: str):
|
||||||
|
"""
|
||||||
|
Returns if account associated with this email has password, i.e is account from Google OAuth
|
||||||
|
"""
|
||||||
|
with Database() as db:
|
||||||
|
data = db.fetchone("""
|
||||||
|
SELECT password
|
||||||
|
FROM users
|
||||||
|
WHERE email = ?
|
||||||
|
""", (email,))
|
||||||
|
return False if data["password"] == None else True
|
||||||
|
|
||||||
def get_session_info_email(email: str) -> dict:
|
def get_session_info_email(email: str) -> dict:
|
||||||
"""
|
"""
|
||||||
Returns username and user_id given email
|
Returns username and user_id given email
|
||||||
|
|||||||
Reference in New Issue
Block a user