Exemple #1
0
	def render_JSON(self, request):
		try:
			username = request.args['username'][0]
			password = request.args['password'][0]
		except KeyError:
			return response('invalid_login', 'Missing username or password')
		user = userAuth(username, password)
		if not user:
			return response('invalid_login', 'No user found with matching username and password')
		return self.render_user_JSON(request, user)
Exemple #2
0
	def __call__(self, *args, **kwargs):
		args[0].setHeader('Content-Type', 'text/plain')
		try:
			username = args[1].args['username'][0]
			password = args[1].args['password'][0]
		except KeyError:
			return responses['invalid_login']
		user = userAuth(username, password)
		if not user:
			return responses['invalid_login']
		if isUserAtLeastMaster(user.id):
			return self.f(*(args + (user,)), **kwargs)
		else:
			return response('insufficient_permissions', 'User does not have master permissions')