예제 #1
0
def login(request):
    redirect_to = request.GET.get('next', '/')
    context = {'user': get_authenticate_user(request)}
    form = LoginForm()
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.login_user(request):
            return HttpResponseRedirect(redirect_to)
    context.update({'form': form})
    return render(request, 'login.html', context)
예제 #2
0
def login(request):
    username = "******"

    if request.method == "POST":
        # Get the posted form
        MyLoginForm = LoginForm(request.POST)

        if MyLoginForm.is_valid():

            username = MyLoginForm.cleaned_data['xyz']

    else:
        MyLoginForm = LoginForm()

    return render(request, 'loggedin.html', {"username": username})
예제 #3
0
파일: views.py 프로젝트: zmts-wr/test_doit
def login_signup(request, signup=False):
    if request.method == 'POST':
        if signup:
            form = SignUpForm(data=request.POST)
            error = None
            if form.is_valid():
                try:
                    user = User.objects.create_user(form.cleaned_data['username'], form.cleaned_data['username'], form.cleaned_data['password'])
                except:
                    error = "Can't create user. Try another email and(or) password."
                else:
                    login(request, user)
                    return redirect(reverse('home'))
            
            return render(request, 'polls/login.html', {
                'signup_form': form,
                'error': error,
                'signup': True,
            })
        else:
            form = LoginForm(data=request.POST)
            if form.is_valid():
                user = authenticate(request, **form.cleaned_data)
                if user:
                    login(request, user)
                    return redirect(reverse('home'))

            return render(request, 'polls/login.html', {
                'login_form': form,
                'error': 'Incorrect user name or password',
            })
    else:
        return render(request, 'polls/login.html')
예제 #4
0
def login(request):
    '''login view'''   
    if request.method == 'POST':
        form=LoginForm(request.POST)
        if form.is_valid():
            user = auth.authenticate(username=form.cleaned_data["username"], password=form.cleaned_data["password"])
            if user is not None and user.is_active:
                # Correct password, and the user is marked "active"
                auth.login(request, user)
                # Redirect to a success page.
                return HttpResponseRedirect('/keenhome/')
            else:
                # Show an error page/redirect to the login page for reinputting
                return HttpResponseRedirect('/keenhome/accounts/login/')
    else:
        form = LoginForm()
        return render_to_response("polls/login.html", {'form':form}, context_instance=RequestContext(request))
예제 #5
0
def index(request):
	if request.method=='POST':
		form = LoginForm(request.POST)
		if form.is_valid():
			data = form.cleaned_data
			username = form.cleaned_data['username']
			password = form.cleaned_data['password']
			#u_name, pwd, user_email, key = form.save()
			#return redirect('/login')
			user = authenticate(username=username, password=password)
			login(request, user)

			return redirect('contact')
		else:
			return render(request,'polls/login.html', {'form': form})
	else:
		form =  LoginForm()
		return render(request,'polls/login.html',{'form':form})
예제 #6
0
def login(request):
    '''login view'''
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.is_valid():
            user = auth.authenticate(username=form.cleaned_data["username"],
                                     password=form.cleaned_data["password"])
            if user is not None and user.is_active:
                # Correct password, and the user is marked "active"
                auth.login(request, user)
                # Redirect to a success page.
                return HttpResponseRedirect('/keenhome/')
            else:
                # Show an error page/redirect to the login page for reinputting
                return HttpResponseRedirect('/keenhome/accounts/login/')
    else:
        form = LoginForm()
        return render_to_response("polls/login.html", {'form': form},
                                  context_instance=RequestContext(request))
예제 #7
0
def login_view(request):
    form = RegistrationForm(request.POST or None)
    form = LoginForm(request.POST or None)
    if form.is_valid():
        username = form.cleaned_data['username']
        password = form.cleaned_data['password']
        login_user = authenticate(username=username, password=password)
        if login_user:
            login(request, login_user)
            return HttpResponseRedirect(reverse('index'))
    context = {'form': form}
    return render(request, 'login.html', context)
예제 #8
0
파일: views.py 프로젝트: GabrielT9/Django
def LoginRequest(request):
	if request.user.is_authenticated():
		return HttpResponseRedirect('/profile/')
	if request.method == 'POST':
		form = LoginForm(request.POST)
		if form.is_valid():
			username = form.cleaned_data['username']
			password = form.cleaned_data['password']
			person = authenticate(username=username, password=password)
			if person is not None:
				login(request, person)
				return HttpResponseRedirect('/profile/')
			else:
				return render_to_response('login.html', {'form': form}, context_instance=RequestContext(request))
		else:
			return render_to_response('login.html', {'form': form}, context_instance=RequestContext(request))
	else:
		'''No esta ingresando el usuario'''
		form = LoginForm()
		context = {'form': form}
		return render_to_response('login.html', context, context_instance=RequestContext(request))
예제 #9
0
def submit(request):
    global file
    MyLoginForm = LoginForm(request.POST)
    if request.method == "POST":
        if MyLoginForm.is_valid():
            number = MyLoginForm.cleaned_data['number']
            url = MyLoginForm.cleaned_data['url']
            file = MyLoginForm.cleaned_data['file']
            with GoogleMapsScraper() as scraper:
                # with open(args, 'r') as urls_file:
                # for url in urls_file:
                error = scraper.sort_by_date(url)
                if error == -1:
                    # store reviews in CSV file
                    n = 0
                    rev = []
                    while n < number:
                        reviews = scraper.get_reviews(n)
                        rev.extend(reviews)
                        n += len(reviews)
                    df = pd.DataFrame(rev)
                    df.to_csv('polls/mydata/gm_reviews.csv', index=False)
    return HttpResponseRedirect(reverse('polls:save_file'))
def connection(request):
    login_form = None

    if request.POST:
        login_form = LoginForm(request.POST)
        if login_form.is_valid():

            data = request.POST.copy()

            try:
                user = UserModel.objects.get(email=data.get('email'),
                                             is_active=True)
                is_check_password = user.check_password(data.get('password'))
            except:
                return redirect('/login')

            if user and is_check_password:
                login(request, user)
                return redirect('/')

    context = {'form': login_form}

    return render(request, 'login.html', context)
예제 #11
0
파일: views.py 프로젝트: Bheem6005/ku-polls
def login_page(request):
    if request.user.is_authenticated:
        return redirect('polls:index')

    if request.method == 'POST':
        username = request.POST.get('username')
        password = request.POST.get('password')

        user = authenticate(request, username=username, password=password)

        if user is not None:
            login(request, user)
            logger.info(
                '[Successful Login]: Username: {}, IP: {}'.format(request.user.username,
                                                                  request.META.get('REMOTE_ADDR')))
            return HttpResponseRedirect(reverse('polls:index'))
        else:
            messages.error(request, 'Username or Password is incorrect')
            logger.warning('[Unsuccessful Login]: Username: {}, IP: {}'.format(request.POST['username'],
                                                                               request.META.get(
                                                                                   'REMOTE_ADDR')))

    return render(request, 'registration/login.html', {'form': LoginForm()})