def get_users(self, portal): user_data = [] for user in User.objects.select_related("user_profile"): try: profile = user.user_profile except models.UserProfile.DoesNotExist: continue if profile.has_access(portal): user_data.append(construct_user_data(profile=profile)) return JsonResponse({"users": user_data})
def get_users(self, portal): user_data = [] for user in User.objects.select_related('user_profile'): try: profile = user.user_profile except models.UserProfile.DoesNotExist: continue if profile.has_access(portal): user_data.append(construct_user_data(profile=profile)) return JsonResponse({'users': user_data})
def authenticate(self, portal, username, password): user = django_authenticate(username=username, password=password) if user: if not user.is_active: return JsonError('User account is disabled') else: try: profile = user.user_profile except models.UserProfile.DoesNotExist: return JsonError('No access to this portal') if profile.has_access(portal): user_data = construct_user_data(profile=profile) return JsonResponse({'user': user_data}) else: return JsonError('No access to this portal') else: logger.warn('Login failed for user %s and ip %s', username, self.request.META['REMOTE_ADDR']) return JsonError('Login failed')
def authenticate(self, portal, username, password): user = django_authenticate(username=username, password=password) if user: if not user.is_active: return JsonError("User account is disabled") else: try: profile = user.user_profile except models.UserProfile.DoesNotExist: return JsonError("No access to this portal") if profile.has_access(portal): user_data = construct_user_data(profile=profile) return JsonResponse({"user": user_data}) else: return JsonError("No access to this portal") else: logger.warn( "Login failed for user %s and ip %s", username, self.request.META["REMOTE_ADDR"], ) return JsonError("Login failed")
def get_user(self, portal, username): try: user = User.objects.get(username=username) except User.DoesNotExist: user = None if user: if not user.is_active: return JsonError("User account is disabled") else: try: profile = user.user_profile except models.UserProfile.DoesNotExist: return JsonError("No access to this portal") if profile.has_access(portal): user_data = construct_user_data(profile=profile) return JsonResponse({"user": user_data}) else: return JsonError("No access to this portal") else: return JsonError( "No such user. " + "Perhaps you need to add user to the SSO server first?")
def get_user(self, portal, username): try: user = User.objects.get(username=username) except User.DoesNotExist: user = None if user: if not user.is_active: return JsonError('User account is disabled') else: try: profile = user.user_profile except models.UserProfile.DoesNotExist: return JsonError('No access to this portal') if profile.has_access(portal): user_data = construct_user_data(profile=profile) return JsonResponse({'user': user_data}) else: return JsonError('No access to this portal') else: return JsonError( 'No such user. ' + 'Perhaps you need to add user to the SSO server first?' )