def create(mail, force=False): ''' create user :param str mail: mail :rtype: dict ''' if not force: oauth_data = OAuthDB().find_one({'_id': mail}, {'owner': 1}) if 'owner' in oauth_data and oauth_data['owner']: raise Exception('mail:`%s` already bind' % mail) user = UsersDB().add(UsersDB.new(mail=mail)) OAuthDB().setup_owner(mail=user['mail'], uid=user['_id']) return user
def create(mail: str, force: bool = False) -> dict[str, Any]: ''' create user Args: mail (str): User mail. force (bool): Force to create. Returns: Return the created data. ''' if not force: oauth_data = OAuthDB().find_one({'_id': mail}, {'owner': 1}) if oauth_data is None: raise Exception(f'mail: `{mail}` not in the oauth dbs') if 'owner' in oauth_data and oauth_data['owner']: raise Exception(f'mail:`{mail}` already bind') user = UsersDB().add(UsersDB.new(mail=mail)) OAuthDB().setup_owner(mail=user['mail'], uid=user['_id']) return user