forked from Hostea/dashboard
chore: fix linting cmd and apply linting
parent
344ffaa4b8
commit
542ce0182d
2
Makefile
2
Makefile
|
@ -32,7 +32,7 @@ help: ## Prints help for targets with comments
|
|||
|
||||
lint: ## Run linter
|
||||
@./venv/bin/black ./dashboard/*
|
||||
@./venv/bin/black ./oauth/*
|
||||
@./venv/bin/black ./accounts/*
|
||||
|
||||
migrate: ## Run migrations
|
||||
$(call run_migrations)
|
||||
|
|
|
@ -2,5 +2,5 @@ from django.apps import AppConfig
|
|||
|
||||
|
||||
class AccountsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'accounts'
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "accounts"
|
||||
|
|
|
@ -4,8 +4,8 @@ from django.urls import path, include
|
|||
from .views import login_view, public_view, logout_view, protected_view
|
||||
|
||||
urlpatterns = [
|
||||
path('login/', login_view, name='accounts.login'),
|
||||
path('logout/', login_view, name='accounts.logout'),
|
||||
path('protected/', protected_view, name='accounts.protected'),
|
||||
path('', public_view, name='accounts.public'),
|
||||
path("login/", login_view, name="accounts.login"),
|
||||
path("logout/", login_view, name="accounts.logout"),
|
||||
path("protected/", protected_view, name="accounts.protected"),
|
||||
path("", public_view, name="accounts.public"),
|
||||
]
|
||||
|
|
|
@ -29,10 +29,15 @@ LOGIN_CONTENT = {
|
|||
"greetings": GREETINGS,
|
||||
}
|
||||
|
||||
|
||||
@csrf_protect
|
||||
def login_view(request):
|
||||
if request.method == "POST":
|
||||
user = authenticate(request, username=request.POST["username"], password=request.POST["password"])
|
||||
user = authenticate(
|
||||
request,
|
||||
username=request.POST["username"],
|
||||
password=request.POST["password"],
|
||||
)
|
||||
if user is not None:
|
||||
login(request, user)
|
||||
print("user logged in")
|
||||
|
@ -40,7 +45,7 @@ def login_view(request):
|
|||
next_url = request.POST["next"]
|
||||
if next_url:
|
||||
return redirect(next_url)
|
||||
return redirect(reverse('accounts.protected'))
|
||||
return redirect(reverse("accounts.protected"))
|
||||
else:
|
||||
return HttpResponse("Login required")
|
||||
|
||||
|
@ -50,14 +55,17 @@ def login_view(request):
|
|||
|
||||
return render(request, "accounts/auth/login.html", ctx)
|
||||
|
||||
|
||||
@login_required
|
||||
def protected_view(request):
|
||||
return render(request, "accounts/protected.html")
|
||||
|
||||
|
||||
@login_required
|
||||
def logout_view(request):
|
||||
logout(request)
|
||||
return redirect(reverse('accounts.login'))
|
||||
return redirect(reverse("accounts.login"))
|
||||
|
||||
|
||||
def public_view(request):
|
||||
return render(request, "accounts/public.html")
|
||||
|
|
Loading…
Reference in New Issue