from mozilla_django_oidc.auth import OIDCAuthenticationBackend

from moderator.moderate.mozillians import is_vouched, BadStatusCodeError


class ModeratorAuthBackend(OIDCAuthenticationBackend):
    def create_user(self, email, **kwargs):
        try:
            data = is_vouched(email)
        except BadStatusCodeError:
            data = None

        if data and data['is_vouched']:
            return super(ModeratorAuthBackend, self).create_user(email, **kwargs)
        return None

from mozilla_django_oidc.auth import OIDCAuthenticationBackend

from moderator.moderate.mozillians import is_vouched, BadStatusCodeError


class ModeratorAuthBackend(OIDCAuthenticationBackend):
    def create_user(self, claims, **kwargs):
        try:
            data = is_vouched(claims.get('email'))
        except BadStatusCodeError:
            data = None

        if data and data['is_vouched']:
            return super(ModeratorAuthBackend, self).create_user(claims, **kwargs)
        return None

Fix claims handling on create_user
Fix claims handling on create_user

  from mozilla_django_oidc.auth import OIDCAuthenticationBackend
  
  from moderator.moderate.mozillians import is_vouched, BadStatusCodeError
  
  
  class ModeratorAuthBackend(OIDCAuthenticationBackend):
-     def create_user(self, email, **kwargs):
+     def create_user(self, claims, **kwargs):
          try:
-             data = is_vouched(email)
+             data = is_vouched(claims.get('email'))
          except BadStatusCodeError:
              data = None
  
          if data and data['is_vouched']:
-             return super(ModeratorAuthBackend, self).create_user(email, **kwargs)
+             return super(ModeratorAuthBackend, self).create_user(claims, **kwargs)
          return None
  
Fix claims handling on create_user
## Code Before:
from mozilla_django_oidc.auth import OIDCAuthenticationBackend

from moderator.moderate.mozillians import is_vouched, BadStatusCodeError


class ModeratorAuthBackend(OIDCAuthenticationBackend):
    def create_user(self, email, **kwargs):
        try:
            data = is_vouched(email)
        except BadStatusCodeError:
            data = None

        if data and data['is_vouched']:
            return super(ModeratorAuthBackend, self).create_user(email, **kwargs)
        return None

## Instruction:
Fix claims handling on create_user
## Code After:
from mozilla_django_oidc.auth import OIDCAuthenticationBackend

from moderator.moderate.mozillians import is_vouched, BadStatusCodeError


class ModeratorAuthBackend(OIDCAuthenticationBackend):
    def create_user(self, claims, **kwargs):
        try:
            data = is_vouched(claims.get('email'))
        except BadStatusCodeError:
            data = None

        if data and data['is_vouched']:
            return super(ModeratorAuthBackend, self).create_user(claims, **kwargs)
        return None
