mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-18 18:47:11 +00:00
Include email in verification API
This commit is contained in:
parent
8e3313156e
commit
5d3da3340f
4 changed files with 6 additions and 6 deletions
|
@ -232,7 +232,7 @@ function EmailSignInContext({
|
||||||
const [otpError, setOTPError] = useState("");
|
const [otpError, setOTPError] = useState("");
|
||||||
|
|
||||||
function checkOTPAndRedirect() {
|
function checkOTPAndRedirect() {
|
||||||
const verifyUrl = `/auth/magic?code=${otp}`;
|
const verifyUrl = `/auth/magic?code=${otp}&email=${email}`;
|
||||||
|
|
||||||
fetch(verifyUrl, {
|
fetch(verifyUrl, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
|
|
@ -269,8 +269,8 @@ async def astart_trial_subscription(user: KhojUser) -> Subscription:
|
||||||
return subscription
|
return subscription
|
||||||
|
|
||||||
|
|
||||||
async def aget_user_validated_by_email_verification_code(code: str) -> KhojUser:
|
async def aget_user_validated_by_email_verification_code(code: str, email: str) -> KhojUser:
|
||||||
user = await KhojUser.objects.filter(email_verification_code=code).afirst()
|
user = await KhojUser.objects.filter(email_verification_code=code, email=email).afirst()
|
||||||
if not user:
|
if not user:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -99,8 +99,8 @@ async def login_magic_link(request: Request, form: MagicLinkForm):
|
||||||
|
|
||||||
|
|
||||||
@auth_router.get("/magic")
|
@auth_router.get("/magic")
|
||||||
async def sign_in_with_magic_link(request: Request, code: str):
|
async def sign_in_with_magic_link(request: Request, code: str, email: str):
|
||||||
user = await aget_user_validated_by_email_verification_code(code)
|
user = await aget_user_validated_by_email_verification_code(code, email)
|
||||||
if user:
|
if user:
|
||||||
id_info = {
|
id_info = {
|
||||||
"email": user.email,
|
"email": user.email,
|
||||||
|
|
|
@ -33,7 +33,7 @@ def is_resend_enabled():
|
||||||
|
|
||||||
|
|
||||||
async def send_magic_link_email(email, unique_id, host):
|
async def send_magic_link_email(email, unique_id, host):
|
||||||
sign_in_link = f"{host}auth/magic?code={unique_id}"
|
sign_in_link = f"{host}auth/magic?code={unique_id}&email={email}"
|
||||||
|
|
||||||
if not is_resend_enabled():
|
if not is_resend_enabled():
|
||||||
logger.debug(f"Email sending disabled. Share this sign-in link with the user: {sign_in_link}")
|
logger.debug(f"Email sending disabled. Share this sign-in link with the user: {sign_in_link}")
|
||||||
|
|
Loading…
Reference in a new issue