def login_page(request): ''' authentication ''' # send user to the login page data = { 'login_form': forms.LoginForm(), 'register_form': forms.RegisterForm(), } return TemplateResponse(request, 'login.html', data)
def login_page(request): ''' authentication ''' # send user to the login page data = { 'site_settings': models.SiteSettings.get(), 'login_form': forms.LoginForm(), 'register_form': forms.RegisterForm(), } return TemplateResponse(request, 'login.html', data)
def user_login(request): ''' authentication ''' # send user to the login page if request.method == 'GET': form = forms.LoginForm() return TemplateResponse(request, 'login.html', {'login_form': form}) # authenticate user form = forms.LoginForm(request.POST) if not form.is_valid(): return TemplateResponse(request, 'login.html', {'login_form': form}) username = form.data['username'] username = '******' % (username, DOMAIN) password = form.data['password'] user = authenticate(request, username=username, password=password) if user is not None: login(request, user) return redirect(request.GET.get('next', '/')) return TemplateResponse(request, 'login.html', {'login_form': form})
def user_login(request): ''' authenticate user login ''' if request.method == 'GET': return redirect('/login') register_form = forms.RegisterForm() login_form = forms.LoginForm(request.POST) if not login_form.is_valid(): return TemplateResponse(request, 'login.html', { 'login_form': login_form, 'register_form': register_form }) username = login_form.data['username'] username = '******' % (username, DOMAIN) password = login_form.data['password'] user = authenticate(request, username=username, password=password) if user is not None: login(request, user) return redirect(request.GET.get('next', '/')) return TemplateResponse(request, 'login.html', { 'login_form': login_form, 'register_form': register_form })