def login_user(request): success = False auth_backend = RequestParamsClientBackend() client = auth_backend.authenticate(request) if client: if request.method == "POST": user = authenticate(email=request.POST['email'], password=request.POST['password']) if user is not None: if user.is_active: # Redirect to a success page. token = AccessToken.objects.create( user=user, client=client, scope=provider.scope.to_int(request.POST['scope']) ) success = True token_view = AccessTokenView() return token_view.access_token_response(token) else: # Return a 'disabled account' error message success = 'False - Account disabled' else: # Return an 'invalid login' error message. success = 'False - Invalid login' return render_to_response('success.json', { 'success': success, }, context_instance=RequestContext(request))
def login_user(request): success = False auth_backend = RequestParamsClientBackend() client = auth_backend.authenticate(request) if client: if request.method == "POST": user = authenticate(email=request.POST['email'], password=request.POST['password']) if user is not None: if user.is_active: # Redirect to a success page. token = AccessToken.objects.create( user=user, client=client, scope=provider.scope.to_int(request.POST['scope'])) success = True token_view = AccessTokenView() return token_view.access_token_response(token) else: # Return a 'disabled account' error message success = 'False - Account disabled' else: # Return an 'invalid login' error message. success = 'False - Invalid login' return render_to_response('success.json', { 'success': success, }, context_instance=RequestContext(request))
def register_user(request): success = False auth_backend = RequestParamsClientBackend() client = auth_backend.authenticate(request) if client: if request.method == "POST": if QualiaUser.objects.filter(email=request.POST['email']).count(): success = 'False - Email exists' else: user = QualiaUser.objects.create_user(request.POST['email'], request.POST['password']) token = AccessToken.objects.create( user=user, client=client, scope=provider.scope.to_int(request.POST['scope']) ) success = True token_view = AccessTokenView() return token_view.access_token_response(token) return render_to_response('success.json', { 'success': success, }, context_instance=RequestContext(request))
def register_user(request): success = False auth_backend = RequestParamsClientBackend() client = auth_backend.authenticate(request) if client: if request.method == "POST": if QualiaUser.objects.filter(email=request.POST['email']).count(): success = 'False - Email exists' else: user = QualiaUser.objects.create_user(request.POST['email'], request.POST['password']) token = AccessToken.objects.create(user=user, client=client, scope=provider.scope.to_int( request.POST['scope'])) success = True token_view = AccessTokenView() return token_view.access_token_response(token) return render_to_response('success.json', { 'success': success, }, context_instance=RequestContext(request))