-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
1,021 additions
and
637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.idea | ||
.pyre/ | ||
example/venv | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
repos: | ||
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster | ||
- repo: https://github.com/psf/black-pre-commit-mirror | ||
rev: 23.12.1 | ||
hooks: | ||
- id: black | ||
# It is recommended to specify the latest version of Python | ||
# supported by your project here, or alternatively use | ||
# pre-commit's default_language_version, see | ||
# https://pre-commit.com/#top_level-default_language_version | ||
language_version: python3.11 | ||
|
||
- repo: https://github.com/fsouza/pre-commit-pyre-check | ||
rev: '199dc59' # Use the sha / tag you want to point at | ||
hooks: | ||
- id: pyre-check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"source_directories": [ | ||
"." | ||
], | ||
"search_path": [ | ||
"env/lib/python3.11/site-packages/" | ||
], | ||
"ignore_all_errors":[ | ||
"*env*/*", | ||
"example/venv/*", | ||
"build/*", | ||
"example/*" | ||
|
||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
from django.shortcuts import render | ||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse | ||
from django.contrib.auth import authenticate,login,logout | ||
from django.contrib.auth import authenticate, login, logout | ||
from django.contrib.auth.models import User | ||
|
||
|
||
def loginView(request): | ||
context={} | ||
if request.method=="POST": | ||
username=request.POST["username"] | ||
password=request.POST["password"] | ||
user=authenticate(username=username,password=password) | ||
context = {} | ||
if request.method == "POST": | ||
username = request.POST["username"] | ||
password = request.POST["password"] | ||
user = authenticate(username=username, password=password) | ||
if user: | ||
from mfa.helpers import has_mfa | ||
res = has_mfa(username = username, request = request) # has_mfa returns false or HttpResponseRedirect | ||
|
||
res = has_mfa( | ||
username=username, request=request | ||
) # has_mfa returns false or HttpResponseRedirect | ||
if res: | ||
return res | ||
return create_session(request,user.username) | ||
context["invalid"]=True | ||
return create_session(request, user.username) | ||
context["invalid"] = True | ||
return render(request, "login.html", context) | ||
|
||
def create_session(request,username): | ||
user=User.objects.get(username=username) | ||
user.backend='django.contrib.auth.backends.ModelBackend' | ||
|
||
def create_session(request, username): | ||
user = User.objects.get(username=username) | ||
user.backend = "django.contrib.auth.backends.ModelBackend" | ||
login(request, user) | ||
return HttpResponseRedirect(reverse('home')) | ||
return HttpResponseRedirect(reverse("home")) | ||
|
||
|
||
def logoutView(request): | ||
logout(request) | ||
return render(request,"logout.html",{}) | ||
return render(request, "logout.html", {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
from django.conf import settings | ||
from django.core.mail import EmailMessage | ||
|
||
try: | ||
from django.urls import reverse | ||
except: | ||
from django.core.urlresolver import reverse | ||
except ImportError: | ||
from django.core.urlresolver import reverse # pyre-ignore[21] | ||
|
||
|
||
def send(to,subject,body): | ||
def send(to, subject, body): | ||
from_email_address = settings.EMAIL_HOST_USER | ||
if '@' not in from_email_address: | ||
if "@" not in from_email_address: | ||
from_email_address = settings.DEFAULT_FROM_EMAIL | ||
From = "%s <%s>" % (settings.EMAIL_FROM, from_email_address) | ||
email = EmailMessage(subject,body,From,to) | ||
email = EmailMessage(subject, body, From, to) | ||
email.content_subtype = "html" | ||
return email.send(False) | ||
|
||
|
||
def get_redirect_url(): | ||
return {"redirect_html": reverse(getattr(settings, 'MFA_REDIRECT_AFTER_REGISTRATION', 'mfa_home')), | ||
"reg_success_msg":getattr(settings,"MFA_SUCCESS_REGISTRATION_MSG")} | ||
return { | ||
"redirect_html": reverse( | ||
getattr(settings, "MFA_REDIRECT_AFTER_REGISTRATION", "mfa_home") | ||
), | ||
"reg_success_msg": getattr(settings, "MFA_SUCCESS_REGISTRATION_MSG"), | ||
} |
Oops, something went wrong.