code: async def login(cls: Type[_SessionT],
                      credentials: AuthenticationCredentials,
                      config: Config) -> _SessionT:
          
          user = credentials.authcid
          password, user_dir = await cls.find_user(config, user)
          if user != credentials.identity:
              raise InvalidAuth()
          elif not credentials.check_secret(password):
              raise InvalidAuth()
          maildir, layout = cls._load_maildir(config, user_dir)
          mailbox_set = MailboxSet(maildir, layout)
          filter_set = FilterSet(layout.path)
          return cls(credentials.identity, config, mailbox_set, filter_set)
docs: Checks the given credentials for a valid login and returns a new
          session.