Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Login(TemplateView):
- # def get(self,request,**kqargs):
- # if request.user.is_authenticated:
- # return render(request,'account/dashboard.html')
- template_name = 'account/login.html'
- def post(self, request, *args, **kwargs):
- context = self.get_context_data()
- if context["form"].is_valid():
- username = context['form'].data['username']
- password = context['form'].data['password']
- user = authenticate(username=username,password=password)
- if user:
- login(request,user)
- return redirect('social:dashboard')
- else:
- return redirect('login-again')
- def get_context_data(self,**kwargs):
- context = super(Login,self).get_context_data(**kwargs)
- context['form'] = LoginForm(self.request.POST or None)
- return context
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement