Example #1
0
def login(request):
	if not request.user.is_authenticated():
		form = LoginForm(request.POST or None)
		if form.is_valid():
			userName = form.cleaned_data['username']
			passWord = form.cleaned_data['password']
			#print passWord
			user = auth.authenticate(username=userName, password=passWord)
			if user is not None:
				auth.login(request, user)
				return HttpResponseRedirect('/tweetboard/')
			return HttpResponse('fail')
		return r2r(request, 'login.html', {'form': form})
	return HttpResponseRedirect('/')
Example #2
0
def register(request):
	if not request.user.is_authenticated():
		form = RegisterForm(request.POST or None)
		if form.is_valid():
			userName = form.cleaned_data['username']
			passWord = form.cleaned_data['password']
			eMail = form.cleaned_data['email']
			firstName = form.cleaned_data['first_name']
			lastName = form.cleaned_data['last_name']
			user = User.objects.create_user(
                        username=userName,
                        email=eMail,
                        password=passWord,
                        )
			url = util.gen_url()
			UserProfile.objects.create(user=user, url=url)
			return HttpResponseRedirect('/')
		return r2r(request, 'register.html', {'form': form})
	return HttpResponseRedirect('/')