mirror of
https://github.com/simple-login/app.git
synced 2024-09-28 20:51:29 +02:00
Bypass 2FA if Login with Proton (#1142)
* Bypass 2FA if Login with Proton * Fix formatting of template
This commit is contained in:
parent
c2bb6488e4
commit
38d305da23
@ -9,12 +9,14 @@ from app.log import LOG
|
|||||||
from app.models import Referral
|
from app.models import Referral
|
||||||
|
|
||||||
|
|
||||||
def after_login(user, next_url):
|
def after_login(user, next_url, login_from_proton: bool = False):
|
||||||
"""
|
"""
|
||||||
Redirect to the correct page after login.
|
Redirect to the correct page after login.
|
||||||
|
If the user is logged in with Proton, do not look at fido nor otp
|
||||||
If user enables MFA: redirect user to MFA page
|
If user enables MFA: redirect user to MFA page
|
||||||
Otherwise redirect to dashboard page if no next_url
|
Otherwise redirect to dashboard page if no next_url
|
||||||
"""
|
"""
|
||||||
|
if not login_from_proton:
|
||||||
if user.fido_enabled():
|
if user.fido_enabled():
|
||||||
# Use the same session for FIDO so that we can easily
|
# Use the same session for FIDO so that we can easily
|
||||||
# switch between these two 2FA option
|
# switch between these two 2FA option
|
||||||
@ -29,7 +31,7 @@ def after_login(user, next_url):
|
|||||||
return redirect(url_for("auth.mfa", next=next_url))
|
return redirect(url_for("auth.mfa", next=next_url))
|
||||||
else:
|
else:
|
||||||
return redirect(url_for("auth.mfa"))
|
return redirect(url_for("auth.mfa"))
|
||||||
else:
|
|
||||||
LOG.d("log user %s in", user)
|
LOG.d("log user %s in", user)
|
||||||
login_user(user)
|
login_user(user)
|
||||||
session["sudo_time"] = int(time())
|
session["sudo_time"] = int(time())
|
||||||
|
@ -137,7 +137,7 @@ def proton_callback():
|
|||||||
return redirect(url_for("auth.login"))
|
return redirect(url_for("auth.login"))
|
||||||
|
|
||||||
if res.redirect:
|
if res.redirect:
|
||||||
return after_login(res.user, res.redirect)
|
return after_login(res.user, res.redirect, login_from_proton=True)
|
||||||
|
|
||||||
next_url = session.get("oauth_next")
|
next_url = session.get("oauth_next")
|
||||||
return after_login(res.user, next_url)
|
return after_login(res.user, next_url, login_from_proton=True)
|
||||||
|
@ -19,9 +19,7 @@
|
|||||||
{% if connect_with_proton %}
|
{% if connect_with_proton %}
|
||||||
|
|
||||||
<div class="my-3">
|
<div class="my-3">
|
||||||
<p>
|
<p>Alternatively you can use your Proton credentials to ensure it's you.</p>
|
||||||
Alternatively you can use your Proton credentials to ensure it's you.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<a class="btn btn-primary btn-block mt-2 proton-button w-25"
|
<a class="btn btn-primary btn-block mt-2 proton-button w-25"
|
||||||
href="{{ url_for("auth.proton_login", next=next) }}">
|
href="{{ url_for("auth.proton_login", next=next) }}">
|
||||||
|
Loading…
Reference in New Issue
Block a user