예제 #1
0
def create_login(user_resource_id, auth_type, auth_key, auth_data=None):
    """
    """

    # Note: Do this in a more api friendly manner....

    # TODO: Try/catch this stuff....
    user_key = get_key_from_resource_id(user_resource_id)
    user = user_key.get()

    if not auth_type == 'basic':
        raise Exception('unsupported provider: %s' % auth_type)

    # Wrap this in a service
    auth_type, auth_key, auth_data = basic.get_login_properties(user, auth_key, auth_data)
    key = AuthUserMethodEntity.generate_key(user.key, auth_type, auth_key)
    login_entity = AuthUserMethodEntity(key=key)

    login_entity.auth_type = auth_type
    login_entity.auth_key = auth_key
    login_entity.auth_data = auth_data
    login_entity.user_key = user.key  # TODO: Eventually it's just resource_id

    login_entity.put()

    login_model = _populate_model(login_entity)
    return login_model
예제 #2
0
def _populate_entity(login_model):
    """
    TODO: WE may no longer need this...
    """
    if not login_model:
        return None

    login_entity = AuthUserMethodEntity(key=get_key_from_resource_id(login_model.id))
    login_entity.auth_type = login_model.auth_type
    login_entity.auth_key = login_model.auth_key
    login_entity.auth_data = login_model.auth_data

    raise Exception(login_model)

    return login_entity
예제 #3
0
def create_login(user, auth_type, auth_key, auth_data=None):
    """
    TODO: Replace this with auth_core.api.logins.create_login
    """

    if not auth_type == 'basic':
        raise Exception('unsupported provider')

    auth_type, auth_key, auth_data = basic.get_login_properties(
        user, auth_key, auth_data)
    key = AuthUserMethodEntity.generate_key(user.key, auth_type, auth_key)
    login = AuthUserMethodEntity(key=key)

    login.auth_type = auth_type
    login.auth_key = auth_key
    login.auth_data = auth_data
    login.user_key = user.key

    login.put()
    return login