Beispiel #1
0
def login_view(request):
	if request.user.is_authenticated():
		return HttpResponseRedirect('/profil/')
	state = "Please login"
	next = ''
	if 'next' in request.GET:		
		next = request.GET['next']

	if request.POST:				# ketika submit data
		form = LoginForm(request.POST)		# isi value pada form sesuai yg di POST
		if form.is_valid():				# cek validasi
			# Data ada di array form.cleaned_data	
		        user = authenticate(
				username=form.cleaned_data['username'],
				password=form.cleaned_data['password']
			)
			if user is not None:
			    if user.is_active:
				login(request, user)								
				state = "You're successfully logged in!"
			    else:
				state = "Your account is not active, please contact the site admin."
			else:
			    state = "Your username and/or password were incorrect."

			return HttpResponseRedirect(next) 		# Redirect after POST
	else:
		form = LoginForm() 			# value form kosongan
	
	datanya = {'form': form, 'state': state, 'next': next}	
	return render_to_response('member/login.html',datanya, context_instance=RequestContext(request, processors=[custom_proc]))
Beispiel #2
0
def login(request):
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.login(request):
            next = request.GET.get("next", "")
            if next:
                return redirect(next)
            return redirect('/')
    else:
        form = LoginForm()

    ctx = { 'form': form,  }
    return render(request, 'member/login.html', ctx)
Beispiel #3
0
def login(request):
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.login(request):
            next = request.GET.get("next", "")
            if next:
                return redirect(next)
            return redirect('/')
    else:
        form = LoginForm()

    ctx = { 'form': form,  }
    return render_to_response('member/login.html', ctx, context_instance=RequestContext(request))
Beispiel #4
0
def login(request):
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.login(request):
            next = request.GET.get("next", "")
            if next:
                return redirect(next)
            return redirect('/')
    else:
        form = LoginForm()

    ctx = { 'form': form,  }
    return render_to_response('member/login.html', ctx, context_instance=RequestContext(request))
Beispiel #5
0
def login(request):
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.login(request):
            next = request.GET.get("next", "")
            if next:
                return redirect(next)
            return redirect('/')
    else:
        form = LoginForm()

    ctx = {
        'form': form,
    }
    return render(request, 'member/login.html', ctx)