docstr: Verify user
  TODO: We might want to use a SyftObject instead
docstr_tok: ["Verify","user","TODO",":","We","might","want","to","use","a","SyftObject","instead"]
code: def exchange_credentials(
      self, context: UnauthedServiceContext
  ) -> Union[UserLoginCredentials, SyftError]:
      """Verify user
      TODO: We might want to use a SyftObject instead
      """
      result = self.stash.get_by_email(
          credentials=self.admin_verify_key(),
          email=context.login_credentials.email,
      )
      if result.is_ok():
          user = result.ok()
          if user is not None and check_pwd(
              context.login_credentials.password,
              user.hashed_password,
          ):
              if (
                  context.node.node_type == NodeType.ENCLAVE
                  and user.role == ServiceRole.ADMIN
              ):
                  return SyftError(
                      message="Admins are not allowed to login to Enclaves."
                      "\n Kindly register a new data scientist account by your_client.register."
                  )
              return user.to(UserPrivateKey)
  
          return SyftError(
              message="No user exists with "
              f"{context.login_credentials.email} and supplied password."
          )
  
      return SyftError(
          message="Failed to retrieve user with "
          f"{context.login_credentials.email} with error: {result.err()}"
      )
  
imports: from typing import List
  from typing import Optional
  from typing import Tuple
  from typing import Union
  from ...abstract_node import NodeType
  from ...exceptions.user import UserAlreadyExistsException
  from ...node.credentials import SyftSigningKey
  from ...node.credentials import SyftVerifyKey
  from ...node.credentials import UserLoginCredentials
  from ...serde.serializable import serializable
  from ...store.document_store import DocumentStore
  from ...types.syft_metaclass import Empty
  from ...types.uid import UID
  from ...util.telemetry import instrument
  from ..action.action_permissions import ActionObjectPermission
  from ..action.action_permissions import ActionPermission
  from ..context import AuthedServiceContext
  from ..context import NodeServiceContext
  from ..context import UnauthedServiceContext
  from ..response import SyftError
  from ..response import SyftSuccess
  from ..service import AbstractService
  from ..service import SERVICE_TO_TYPES
  from ..service import TYPE_TO_SERVICE
  from ..service import service_method
  from ..settings.settings_stash import SettingsStash
  from .user import User
  from .user import UserCreate
  from .user import UserPrivateKey
  from .user import UserSearch
  from .user import UserUpdate
  from .user import UserView
  from .user import UserViewPage
  from .user import check_pwd
  from .user import salt_and_hash_password
  from .user_roles import DATA_OWNER_ROLE_LEVEL
  from .user_roles import GUEST_ROLE_LEVEL
  from .user_roles import ServiceRole
  from .user_roles import ServiceRoleCapability
  from .user_stash import UserStash
label_desc: Use image node_id 11 for calling the UserService obj's underlying member method code with example usage: obj.exchange_credentials(context) and returns: SyftError, SyftError, user, SyftError