32 lines
859 B
Python
32 lines
859 B
Python
from django.contrib.auth import login
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
from django.contrib.auth.views import LoginView, LogoutView
|
|
from django.urls import reverse_lazy
|
|
from django.views.generic import CreateView, TemplateView
|
|
|
|
from .forms import SignupForm
|
|
|
|
|
|
class SignupView(CreateView):
|
|
form_class = SignupForm
|
|
template_name = "users/signup.html"
|
|
success_url = reverse_lazy("core:dashboard")
|
|
|
|
def form_valid(self, form):
|
|
response = super().form_valid(form)
|
|
login(self.request, self.object)
|
|
return response
|
|
|
|
|
|
class UserLoginView(LoginView):
|
|
template_name = "users/login.html"
|
|
redirect_authenticated_user = True
|
|
|
|
|
|
class UserLogoutView(LogoutView):
|
|
next_page = reverse_lazy("core:home")
|
|
|
|
|
|
class ProfileView(LoginRequiredMixin, TemplateView):
|
|
template_name = "users/profile.html"
|