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 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 vlogin(request): vlogout(request) if request.method=='POST': form=LoginForm(request.POST) if form.is_valid(): username=request.POST.get('username') moi_password=request.POST.get('password') url=request.POST.get('/') user=authenticate(username=username,password=moi_password) if user is not None: if user.is_active: login(request, user) else: return HttpResponse('User None') sessid=do_login(login,moi_password,username) if sessid is not None: response=HttpResponseRedirect('/') response.set_cookie('sessionid',sessid, httponly=True,expires=datetime.now()+timedelta(days=5) ) return response else: return HttpResponse('What is it?') else: return HttpResponse('User no exist') else: form=LoginForm() return render(request, 'login.html', { 'form': form, })
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 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 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(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 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): 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() : 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 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 login_view(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = authenticate(request, **form.cleaned_data) route = 'qa:login' if user is not None: login(request, user) route = 'qa:main_page' return HttpResponseRedirect(reverse(route)) else: form = LoginForm() return render(request, 'qa/login.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 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): 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_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) if user != None: resp = HttpResponseRedirect('/') #Replace to request.next return resp else: form = LoginForm() return render(request, '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 = 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 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): 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 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_form(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): user = form.save() if user is not None: if user.is_active: login(request, user) return HttpResponseRedirect('/') else: form = LoginForm() return render(request, 'loginform.html', { 'form': form, 'path': request.path, })
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_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 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(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_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_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 do_login(request): error = '' if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = form.save() if user is not None: login(request, user) response = HttpResponseRedirect('/') # response.set_cookie('sessionid', key, path='/', expires=datetime.now()+timedelta(days=5)) return response else: error = user else: error = 'Form not valid' form = LoginForm() return render(request, 'qa/login.html', {'form': form, 'error': error})
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 user_login(request): """With a GET request, a form for entering data should be displayed, with a POST request, a login is made to the site, the redirect to the main page is returned. The user should receive an authorization cookie named sessionid. """ form = LoginForm(request.POST) if request.method == 'POST' and 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 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 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 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 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(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 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})
def login_page(request, *args, **kwargs): error = '' if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): username, password = form.save() user = authenticate(username=username, password=password) logger.debug('user: {}'.format(user)) if user is not None: login(request, user) response = HttpResponseRedirect('/') response.set_cookie('sessid', request.session.session_key, expires=dt.datetime.now() + dt.timedelta(days=5)) return response else: error = u'Wrong password or username' form = LoginForm() return render(request, 'login.html', {'error': error, '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, })