def login_user(request): """Login view.""" if request.user.is_authenticated(): return HttpResponseRedirect(reverse('root', kwargs={})) login_error_msg = None if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): auth_user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password']) if auth_user: login(request, auth_user) return HttpResponseRedirect(reverse('root', kwargs={})) else: login_error_msg = 'Login error' else: form = LoginForm() context = { 'form': form, 'error': login_error_msg } return render(request, 'login.html', context)
def login(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = form.load() auth.login(request, user) return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'login.html', { 'form': form })
def user_login(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = form.save() if user is not None: login(request, user) return HttpResponseRedirect('/') form = LoginForm() return render(request, 'login.html', {'form': form})
def login_view(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = authenticate(**form.cleaned_data) if user: login(request, user) return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'login.html', { 'form': form, })
def login(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = form.save() request.session.flush() request.session['user'] = user.id return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'login_form.html', { 'form': form, })
def login_user(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): user = authenticate(username=request.POST.get('username'), password = request.POST.get('password')) if user is not None and user.is_active: login(request,user) return HttpResponseRedirect("/") else: form = LoginForm() return render(request, 'qa/login.html', { 'form': form })
def mylogin(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password) if user is not None: login(request, user) return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'login.html', {'form': form})
def log_in(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): username = form.cleaned_data['username'] password = form.cleaned_data['password'] user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) return HttpResponseRedirect(reverse('index')) else: form = LoginForm() return render(request, 'login.html', {'form': form})
def login(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): username = request.POST['username'] password = request.POST['password'] user = auth.authenticate(username=username, password=password) if user is not None and user.is_active: auth.login(request, user) return HttpResponseRedirect('/') return HttpResponseRedirect('/login.html') else: form = LoginForm() return render(request, 'qa/login.html', {'form': form})
def loginn(request): error = '' if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = authenticate(**form.cleaned_data) if user: login(request, user) return redirect('main') else: error = 'Invalid username or password. Try again!' else: form = LoginForm() return render(request, 'qa/login.html', {'form': form, 'error': error})
def login(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): username = request.POST['username'] password = request.POST['password'] user = authenticate(username = username, password = password) auth_login(request, user) return HttpResponseRedirect(reverse('homepage')) else: form = LoginForm() return render(request, 'login.html', { 'form' : form })
def login(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = form.save(request) if user != None: resp = HttpResponseRedirect('/') #Replace to request.next return resp else: form = LoginForm() return render(request, 'login.html', { 'form': form, })
def dolog(request): user = request.user if user.is_authenticated(): return HttpResponseRedirect("/") if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): form.log(request) return HttpResponseRedirect("/") else: form = LoginForm() return render(request, 'qa/formlogin.html', { 'form': form })
def login_view(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): username = form.cleaned_data["username"] password = form.cleaned_data["password"] user = authenticate(username=username, password=password) if user is not None: login(request, user) response = HttpResponseRedirect('/') response.set_cookie('sessionid', 'sessionid') return response else: form = LoginForm() return render(request, 'login.html', {'form': form})
def login(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): sessionid = form.save() if sessionid: url = request.GET.get('continue', '/') response = HttpResponseRedirect(url) response.set_cookie('sessionid', sessionid, '''domain='.site.com' ''', httponly=True, expires=datetime.now() + timedelta(days=5)) return response form = LoginForm() return render(request, 'login.html', { 'form': form })
def login_view(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password) if user is not None: login(request, user) return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'login.html', { 'form': form, 'user': request.user, 'session': request.session, })
def login_add(request): #logger.debug(request) if request.method == 'POST': #logger.debug('login_add:' + request.method) form = LoginForm(request.POST) #logger.debug('login_add POST:' + request.POST['username'] + ',pass='******'password']) if form.is_valid(): #logger.debug('login_add form.is_valid:') user = form.save() if user is not None: logout(request) login(request,user) #logger.debug('login_add login') return HttpResponseRedirect('/') form = LoginForm() return render(request, 'login.html', {'form': form,})
def login_page(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): username = form.cleaned_data['username'] password = form.cleaned_data['password'] user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) return HttpResponseRedirect("/") # Redirect to a success page. #else: # Return a 'disabled account' error message #else: # Return an 'invalid login' error message. if request.method == "GET": form = LoginForm() return render(request, 'login.html', { 'title': 'Aut-n', 'form': form, 'button-text': 'Enter', })
def login_view(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): username = form.cleaned_data.get('username') password = form.cleaned_data.get('password') user = authenticate(username=username, password=password) if user is not None: if user.is_authenticated: login(request, user) else: form.add_error( None, "Login Failed! Enter the username and password correctly!") return render(request, 'qa/login.html', { 'form': form, }) if request.POST.get('next', '/').strip() != "": return redirect(request.POST.get('next', '/')) else: return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'qa/login.html', { 'form': form, })
def login_add(request): #logger.debug(request) error = '' if request.method == 'POST': #logger.debug('login_add:' + request.method) form = LoginForm(request.POST) url = request.POST.get('continue', '/') sessid = do_login(form.login, form.password) if sessid: user = form.save() if user is not None: logout(request) login(request,user) #logger.debug('login_add login') return HttpResponseRedirect('/') form = LoginForm() return render(request, 'login.html', {'form': form,})
def login_view(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): username = form.cleaned_data["username"] password = form.cleaned_data["password"] print(username, password) user = authenticate(username=username, password=password) print(type(user)) if user is not None: if user.is_active: login(request, user) return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'login.html', {'form': form, 'user': request.user, 'session': request.session, })
def mylogin(request): message = '' if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password) if user is not None: login(request, user) return HttpResponseRedirect('/') else: message = 'username or password are incorrect' else: form = LoginForm() return render(request, 'qa/login.html',{ 'form': form, 'message':message, })
def loginAsk(request, *args, **kwargs): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): cleaned_data = form.clean() user = authenticate(username=cleaned_data['username'],\ password = cleaned_data['password']) login(request, user) # user = form.logIn() url = '/' return HttpResponseRedirect(url) else: form = LoginForm() return render ( request, 'qa/LoginForm.html', { 'form': form, })
def login(request) : if request.method == "POST" : form = LoginForm(request.POST) if form.is_valid() : form.set_password(request.POST.get("password")) user = form.loginUser(request) return HttpResponseRedirect("/") else : form = LoginForm() return render(request, 'ask_add.html', { 'form' : form, })
def login(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): username = form.cleaned_data.get('username') password = form.cleaned_data.get('password') logger.debug('authenticating name / password: %s / %s', username, password) user = authenticate(username=username, password=password) logger.debug('authenticated user %s', user) if user: auth_login(request, user) request.session.set_test_cookie() request.session['sessionid'] = request.session[SESSION_KEY] return HttpResponseRedirect(reverse('main_page')) else: form = LoginForm() return render(request, 'qa/login.html', {'form': form})
def loginview(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): username = request.POST.get('username') password = request.POST.get('password') user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) return HttpResponseRedirect('/') else: form = LoginForm() error = "Bad login or password" return render(request, 'login.html', { 'form': form, 'user': request.user, 'session': request.session })
def login_(request): if request.method == 'POST': user = authenticate( username=request.POST['username'], password=request.POST['password'], ) if user is not None: login(request, user) return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'login.html', {'form': form})
def login_page(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = form.save() login(request, user) print(request.GET) if 'next' in request.GET: url = request.GET['next'] else: url = reverse('home') print(url) return HttpResponseRedirect(url) else: form = LoginForm() if 'success' in request.GET: text = request.GET['success'] return render(request, 'login.html', mixin({ 'form': form, 'text': text, })) if 'next' in request.GET: return render(request, 'login.html', mixin({ 'form': form, 'next': request.GET['next'] })) return render(request, 'login.html', mixin({'form': form}))
def user_login(request, *args, **kwargs): error = '' # Error msg - "Incorrect username or password.". if request.method == "POST": form = LoginForm(request.POST) if form.is_valid() == True: my_login = form.save() username = my_login['uname'] password = my_login['upass'] url = '/' user = authenticate(username=username, password=password) if user != None: login(request, user) print('User %s is login.' % username) response = HttpResponseRedirect(url) return response error = 'Incorrect username or password.' print('Incorrect username or password for user=%s' % username) return render(request, 'login.html', { 'form': form, 'error': error, 'is_user': False, }) else: return render(request, 'login.html', { 'form': form, 'error': error, 'is_user': False, }) else: form = LoginForm() return render(request, 'login.html', { 'form': form, 'error': error, 'is_user': False, })
def myLogin(request): if request.method == 'POST': form = LoginForm(request.POST) form.is_valid() user = form.save() if user is not None: login(request, user) return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'login.html', {'form': form})
def user_login(request, *args, **kwargs): error = '' if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): url = '/' sessionid = do_login(form.cleaned_data['username'], form.cleaned_data['password']) if sessionid: response = HttpResponseRedirect(url) response.set_cookie('sessionid', sessionid, domain='127.0.0.1', path='/', httponly=True, expires=datetime.now()+timedelta(days=5) ) return response else: error = u'Incorrect login/password' else: form = LoginForm() return render(request, 'qa/login.html', { 'error': error, 'form': form, })
def user_login(request): error = '' if request.method == 'POST': username = request.POST['username'] password = request.POST['password'] user = check_login(username, password) url = request.POST.get('continue', '/') if user is not None: login(request, user) return HttpResponseRedirect(url) else: error = u'Неверный логин / пароль' return render(request, 'qa/login.html', {'form': LoginForm(), 'error': error })
def question_add(request): user = request.user if user.is_authenticated(): if request.method == 'POST': form = AskForm(request.POST) form._user = request.user if form.is_valid(): question = form.save() url = question.get_url() return HttpResponseRedirect(url) else: form = AskForm() return render(request, 'question_add.html', {'form': form}) else: form = LoginForm() return render(request, 'login.html', {'form': form})
def user_login(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = form.save() if user is not None: login(request, user) return HttpResponseRedirect('/') form = LoginForm() context = {'form': form} return render(request, 'login.html', context)
def login(request, *args, **kwargs): if request.method == 'POST': login = request.POST.get('username') password = request.POST.get('password') sessionid = do_login(login, password) if sessionid: response = HttpResponseRedirect('/') response.set_cookie( 'sessionid', sessionid, ) return response else: error = 'Wrong login/password' error = None form = LoginForm() return render(request, 'login.html', {'form': form, 'error': error})
def login(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): form.set_password(request.POST.get("password")) user = form.loginUser(request) return HttpResponseRedirect("/") else: form = LoginForm() return render(request, 'ask_add.html', { 'form': form, })
def login(request): error = '' if request.method == 'POST': login = request.POST.get('username') password = request.POST.get('password') url = '/' sessid = do_login(login, password) if sessid: response = HttpResponseRedirect(url) response.set_cookie('sessionid', sessid, httponly=True, expires=datetime.now()+timedelta(days=5) ) return response else: error = 'Wrong login/password' form = LoginForm() return render(request, 'qa/login.html', {'error': error, 'form': form})
def login(request): if request.method == "POST": username = request.POST['username'] password = request.POST['password'] #form = LoginForm(request.POST) user = auth.authenticate(username=username, password=password) if user is not None: auth.login(request,user) print("AUTH OK") return HttpResponseRedirect('/') else: print("AUTH NOT OK") return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'login.html', { 'form' : form, })
def login(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): user = form.save() log_in(request, user) return HttpResponseRedirect("/") else: form = LoginForm() return render(request, 'qa/login.html', { 'form': form, 'username': request.user.username })
def login(request): error = '' if request.method == 'POST': username = request.POST.get('username') password = request.POST.get('password') url = request.POST.get('continue', '/') sessionid = do_login(username, password) if sessionid: response = HttpResponseRedirect(url) response.set_cookie('sessionid', sessionid, domain='.', httponly=True, expires = datetime.now()+timedelta(days=5)) return response else: error = u'Неверный логин / пароль' else: form = LoginForm() return render(request, 'login.html', {'form': form}) return render(request, 'login.html', {'error': error })
def login(request): error = '' if request.method == 'POST': login = request.POST.get('username') password = request.POST.get('password') url = request.POST.get('continue', '/') sessid = do_login(login, password) if sessid: response = HttpResponseRedirect(url) response.set_cookie('sessionid', sessid) return response else: error = 'Bad login or password' else: form = LoginForm() return render(request, 'login.html', { 'form': form, 'error': error, })
def login(request): error = None if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = form.login() if user is None: error = 'Wrong username or password' else: return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'login_template.html', {'form': form, 'error': error})
def ask(request): user = request.user if user.is_authenticated(): if request.method == "POST": form = AskForm(request.POST) form._user = request.user if form.is_valid(): post = form.save() url = post.get_url() return HttpResponseRedirect(url) else: form = AskForm() return render(request, 'ask.html', { 'form': form, 'user': request.user, }) else: form = LoginForm() return render(request, 'login.html', {'form': form})
def login_user(request): error = '' if request.method == 'POST': url = request.POST.get('continue', '/') form = LoginForm(request.POST) if form.is_valid(): user = form.save() if user is not None and user.is_active: login(request, user) return HttpResponseRedirect(url) else: error = 'Incorrect username or password' else: form = LoginForm() return render(request, 'login.html', {'form': form, 'error': error})
def login_view(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): user = form.save() if user is not None: logout(request) login(request, user) return HttpResponseRedirect('/') form = LoginForm() return render(request, 'login.html', { 'form': form, 'user': request.user, 'session': request.session, })
def loginView(request, *args, **kwargs): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) return HttpResponseRedirect('/') form = LoginForm() form.non_field_errors = ['Пользователь заблокирован'] else: form = LoginForm() form.non_field_errors = ['Неверные учетные данные'] else: form = LoginForm() return render(request, 'login-signup-template.html', {'form': form, 'title': 'Login', 'signup': False})