fix(otp): redirect to setup otp
This commit is contained in:
parent
2ca8ba1398
commit
76cde52404
3 changed files with 11 additions and 3 deletions
|
@ -2,4 +2,9 @@
|
||||||
--accent: #ed333b;
|
--accent: #ed333b;
|
||||||
--accent-bg: #bab3ab;
|
--accent-bg: #bab3ab;
|
||||||
--bg: #f6f5f4;
|
--bg: #f6f5f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* hide hidden things in flexbox */
|
||||||
|
[hidden] {
|
||||||
|
display: none;
|
||||||
}
|
}
|
|
@ -14,9 +14,10 @@ class UserConnectionForm(forms.ModelForm):
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@otp_required
|
|
||||||
def list_connections(request: HttpRequest):
|
def list_connections(request: HttpRequest):
|
||||||
user = request.user
|
user = request.user
|
||||||
|
if not user.is_verified():
|
||||||
|
return redirect("two_factor:setup")
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
form = UserConnectionForm(request.POST)
|
form = UserConnectionForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
|
@ -39,9 +40,9 @@ def list_connections(request: HttpRequest):
|
||||||
return render(request, "connection_list.html", context={"connections": connections, "form": form})
|
return render(request, "connection_list.html", context={"connections": connections, "form": form})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@otp_required
|
@otp_required
|
||||||
def toggle_connection(request: HttpRequest, connection_id: int):
|
def toggle_connection(request: HttpRequest, connection_id: int):
|
||||||
|
|
||||||
if request.method != "POST" or "state" not in request.POST:
|
if request.method != "POST" or "state" not in request.POST:
|
||||||
return HttpResponseBadRequest()
|
return HttpResponseBadRequest()
|
||||||
if request.POST["state"] not in ["enabled", "disabled"]:
|
if request.POST["state"] not in ["enabled", "disabled"]:
|
||||||
|
@ -58,7 +59,7 @@ def toggle_connection(request: HttpRequest, connection_id: int):
|
||||||
return redirect("connections_list")
|
return redirect("connections_list")
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
# @login_required
|
||||||
@otp_required
|
@otp_required
|
||||||
def delete_connection(request: HttpRequest, connection_id: int):
|
def delete_connection(request: HttpRequest, connection_id: int):
|
||||||
connection = get_object_or_404(UserConnection, pk=connection_id)
|
connection = get_object_or_404(UserConnection, pk=connection_id)
|
||||||
|
|
|
@ -143,6 +143,8 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||||
|
|
||||||
LOGOUT_REDIRECT_URL = "connections_list"
|
LOGOUT_REDIRECT_URL = "connections_list"
|
||||||
LOGIN_URL = "two_factor:login"
|
LOGIN_URL = "two_factor:login"
|
||||||
|
# 15 days
|
||||||
|
TWO_FACTOR_REMEMBER_COOKIE_AGE = 1296000
|
||||||
# this one is optional
|
# this one is optional
|
||||||
# LOGIN_REDIRECT_URL = 'two_factor:profile'
|
# LOGIN_REDIRECT_URL = 'two_factor:profile'
|
||||||
STATIC_ROOT = BASE_DIR / "static"
|
STATIC_ROOT = BASE_DIR / "static"
|
||||||
|
|
Loading…
Reference in a new issue