Exemple #1
0
function processLogin($request, $provider)
{
    //don't attempt to login already logged in users
    if (MM_Utils::isLoggedIn()) {
        $loggedInUser = MM_Utils::getCurrentUser();
        $redirectUrl = isset($request['redirect_url']) ? $request['redirect_url'] : MM_CorePageEngine::getUrl(MM_CorePageType::$MEMBER_HOME_PAGE, null, $loggedInUser);
        wp_redirect($redirectUrl);
        exit;
    }
    //either login using a linked account, or using the email (if provided) by the social media account, with that order of precedence
    $authResponse = $provider->authenticate();
    if (!MM_Response::isSuccess($authResponse)) {
        //error authenticating
        throw new Exception("Error authenticating with social network", "1001015");
    }
    $profileResponse = $provider->getUserProfile();
    if (!MM_Response::isSuccess($profileResponse)) {
        //error retrieving profile
        throw new Exception("Error retrieving social network profile", "1001005");
    }
    $profile = $profileResponse->message;
    if (!isset($profile->identifier) || empty($profile->identifier)) {
        //invalid profile identifier
        throw new Exception("Error retrieving social network profile identier or identifier was invalid", "1001006");
    }
    $socialNetworkUniqueIdentifier = $profile->identifier;
    $userAccountResponse = $provider->findLinkedUserByIdentifier($socialNetworkUniqueIdentifier);
    if (MM_Response::isSuccess($userAccountResponse)) {
        $loginUser = $userAccountResponse->message;
    } else {
        if ($provider->getEmailHandlingStrategy() == MM_AbstractSocialLoginExtension::$EMAIL_PROVIDED) {
            //couldnt locate a linked account, either because it doesnt exist or there was an error, try using profile email
            $email = isset($profile->emailVerified) ? $profile->emailVerified : (isset($profile->email) ? $profile->email : "");
            if (empty($email)) {
                throw new Exception("Unable to login: account not linked and no user account found with the supplied email", "1001002");
            }
            $loginUser = MM_User::findByEmail($email);
            if (!$loginUser->isValid()) {
                throw new Exception("Unable to login: account not linked and no valid user account found with the supplied email", "1001003");
            }
        } else {
            throw new Exception("Unable to login: account not linked and provider doesn't supply email", "1001001");
        }
    }
    //we have the user now
    $userHooks = new MM_UserHooks();
    $redirectUrl = isset($request['redirect_url']) ? $request['redirect_url'] : MM_CorePageEngine::getUrl(MM_CorePageType::$MEMBER_HOME_PAGE, null, $loginUser);
    $userHooks->doAutoLogin($loginUser->getId(), $redirectUrl);
    //end login block
    exit;
}
Exemple #2
0
<?php

/**
 *
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
require_once "../../../../../../../wp-config.php";
global $current_user;
$userHooks = new MM_UserHooks();
if ($userHooks->checkEmployeeAccess() === false) {
    $url = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCESS_DENIED);
    wp_redirect($url);
    exit;
}
$export_type = isset($_GET['export_type']) ? $_GET['export_type'] : "standard";
$includeBundleInfo = false;
if ($export_type == 'standard' || $export_type == 'canceled_bundles') {
    if ((!isset($_GET['membership_id']) || !is_numeric($_GET['membership_id'])) && (!isset($_GET['bundle_id']) || !is_numeric($_GET['bundle_id']))) {
        exit;
        //must have membership ID or bundle ID
    }
    if (isset($_GET['membership_id'])) {
        $includeBundleInfo = true;
        $membership = new MM_MembershipLevel();
        $membership->setId($_GET['membership_id']);
        $membership->getData();
        if (!$membership->isValid()) {
            exit;
        }
        $filename = preg_replace("/([^A-za-z0-9\\s])/", "", strtolower($membership->getName()));