예제 #1
0
def login_view(request):
    if request.method == "POST":
        form = AuthenticateForm(data=request.POST)
        if form.is_valid():
            login(request, form.get_user())
            #Success
            return redirect('/')
예제 #2
0
def login_view(request):
	if request.method == 'POST':
		form = AuthenticateForm(data=request.POST)
		if form.is_valid():
			login(request, form.get_user())
			return redirect('/')
		else:
			return index(request, auth_form=form)
예제 #3
0
파일: views.py 프로젝트: mhb11/ribbit
def login_view(request): #logs the user in
    if request.method == 'POST': # expects a HTTP POST request for the login (since the form's method is POST)
        form = AuthenticateForm(data=request.POST)
        if form.is_valid(): #If form validation is successful, login the user using the login() method which starts the session and then redirects to the root url.
            login(request, form.get_user())
            # Success
            return redirect('/')
        else:
            # Failure
            return index(request, auth_form=form) #pass the instance of the auth_form received from the user to the index function and list the errors
    return redirect('/') #if the request isn't POST then the user is redirected to the root url
예제 #4
0
def login_view(request):
    if request.method == 'POST':
        form = AuthenticateForm(data=request.POST)
        if form.is_valid():
            login(request, form.get_user())
            # Success
            return redirect('/')
        else:
            # Failure
            return index(request, auth_form=form)
    return redirect('/')