Esempio n. 1
0
def view_login(request):
	user = User()
	errCode = user.login(request.POST['user'], request.POST['password'])
	data = { 'errCode': errCode }
	if (errCode == User.SUCCESS):
		thisUser = User.objects.get(user=request.POST['user'], password=request.POST['password'])
		data['count'] = thisUser.count
	
	if 'count' not in data:
		return render(request, 'index.html', {'error_message': user.errorMessage(errCode)})

	return render(request, 'login.html', {'user': request.POST['user'], 'count': thisUser.count})
Esempio n. 2
0
def user_login(request):
	"""
	Login User
	"""
	if request.content_type != 'application/json':
		# fix this up at some point
		return Response("Unrecognized request", status = status.HTTP_404_NOT_FOUND)
	user = User()
	errCode = user.login(request.DATA['user'], request.DATA['password'])
	data = { 'errCode': errCode }
	if (errCode == User.SUCCESS):
		thisUser = User.objects.get(user=request.DATA['user'], password=request.DATA['password'])
		data['count'] = thisUser.count
	return Response(data)