コード例 #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
ファイル: views.py プロジェクト: pace-noge/django-ribbit
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('/')