예제 #1
0
 def test_repr(self) -> None:
     self.assertEqual(
         repr(
             auth_domain.UserAuthDetails('uid', 'g_auth_id', 'f_auth_id',
                                         'pid', True)),
         'UserAuthDetails(user_id=%r, gae_id=%r, firebase_auth_id=%r, '
         'parent_user_id=%r, deleted=%r)' %
         ('uid', 'g_auth_id', 'f_auth_id', 'pid', True))
예제 #2
0
 def test_to_dict(self) -> None:
     self.assertEqual(
         auth_domain.UserAuthDetails('uid', 'g_auth_id', 'f_auth_id', 'pid',
                                     True).to_dict(), {
                                         'gae_id': 'g_auth_id',
                                         'firebase_auth_id': 'f_auth_id',
                                         'parent_user_id': 'pid',
                                         'deleted': True,
                                     })
예제 #3
0
def get_user_auth_details_from_model(user_auth_details_model):
    """Returns a UserAuthDetails domain object from the given model.

    Args:
        user_auth_details_model: UserAuthDetailsModel. The source model.

    Returns:
        UserAuthDetails. The domain object with values taken from the model.
    """
    return auth_domain.UserAuthDetails(
        user_auth_details_model.id,
        user_auth_details_model.gae_id,
        user_auth_details_model.firebase_auth_id,
        user_auth_details_model.parent_user_id,
        deleted=user_auth_details_model.deleted)
예제 #4
0
def create_profile_user_auth_details(user_id, parent_user_id):
    """Returns a domain object for a new profile user.

    Args:
        user_id: str. A user ID produced by Oppia for the new profile user.
        parent_user_id: str. The user ID of the full user account which will own
            the new profile account.

    Returns:
        UserAuthDetails. Auth details for the new user.

    Raises:
        ValueError. The new user's parent is itself.
    """
    if user_id == parent_user_id:
        raise ValueError('user cannot be its own parent')
    return auth_domain.UserAuthDetails(user_id, None, None, parent_user_id)