Пример #1
0
    /**
     * Add message to session message stack to appear on page reload
     * @param  string $copy         The text the message should include
     * @param  string $identifier   The specific item the message is related to
     * @param  string $type         Type of message ('success', 'error', 'notice')
     */
    public function addSessionMessage($copy, $identifier = '', $type = 'success')
    {
        $sessionMessages = (array) Session::get($this->messagesSessionName);
        if (!isset($sessionMessages[$type])) {
            $sessionMessages[$type] = array();
        }

        $sessionMessages[$type][] = array(
            'identifier' => $identifier,
            'copy'       => $copy,
        );

        Session::set($this->messagesSessionName, $sessionMessages);
    }
Пример #2
0
    /**
     * Login process
     */
    protected function _login()
    {
        // Can't access if already logged in as Member
        if (\CPFCMembers\Auth::isLoggedIn()) {
            wp_redirect(cpfc_home_url(CPFC_MEMBERS_HOME_URL, CPFC_MEMBERS_HTTP_MODE), 301);
            exit();
        }

		// Resend registration email for unverified members
		if(($email = Input::get('resend')) && ($member = \CPFCMembers\UserModel::loadBy('email_address',$email)) && $member->getRegistrationStatus() == 'unverified'){
            $form = \CPFCMembers\LoginForm::getInstance();
            $form->setValues(array('email_address' => $email));
			$form->addError('form','Thanks, we\'ve sent that to you now. Please check your email and click on the verification link, and then you\'ll be able to login.
<br /><br />
If you\'re still having problems, email us at: help@eagles.cpfc.co.uk');
			$email = new \CPFCMembers\Email('email_templates/verification_email_request', array('User'=>$member));
			$email->send($member->getEmailAddress(), 'Your Email Verification Request');
		}

        $Auth = \CPFCMembers\Auth::getInstance();

        if (Input::isPost()) {
            $form = \CPFCMembers\LoginForm::getInstance();
            $form->setValues(Input::post());
            $form->validate();

            if ($form->isValid()) {

				// Check for valid user
		        if(($user = get_user_by('email', $form->getValue('email_address'))) && wp_check_password($form->getValue('password'),$user->user_pass)){
					// Block unverified members after nth login attempt
	        		if(($member = \CPFCMembers\UserModel::loadBy('id',$user->ID)) && $member->getLoginCount() >= 3 && $member->getRegistrationStatus() == 'unverified'){
						$form->addError('form', 'It doesn\'t look like you\'ve confirmed your email address yet by clicking on the link in the email we sent you. To access the digital member\'s portal, please check your inbox and click on the verification link.
<br /><br />
If you would like us to send a new confirmation email, please <a href="?resend='.urlencode($form->getValue('email_address')).'">click here</a>.');
						return false;
		        	}
		        }

                if (!$Auth->authenticate($form->getValue('email_address'), $form->getValue('password'), $form->getValue('long_login') ? true : false)) {
                    $form->addError('form', 'Username and/or password incorrect.');
                    return false;
                }

				if($loginRedirect = \CPFCMembers\Session::get('login_redirect')){
					\CPFCMembers\Session::delete('login_redirect');
				}
				else{
					$loginRedirect = cpfc_home_url(CPFC_MEMBERS_HOME_URL, CPFC_MEMBERS_HTTP_MODE);
				}

                wp_redirect($loginRedirect, 301);
                exit();
            }
        }
    }
Пример #3
0
<?php
/**
 * 404 page
 */
 
// we don't want to redirect to a 404 on login
\CPFCMembers\Session::delete('login_redirect');
 
get_header(); ?>

<div id="sb-site">

    <?php
    get_partial('partials/cookie_policy');

    if (\CPFCMembers\Auth::isLoggedIn()) {
        get_partial('partials/header_logged_in');
    } else {
        get_partial('partials/header_logged_out', array('showLogin'=>true));
    } ?>

     <!-- 404 -->
    <section class="fullwidth fourzerofour">
        <div class="container">
            <div class="row">

                <div class="col-sm-3 col-sm-offset-1 hidden-xs">
                    <?php $image = get_field('404_error_image', 'option'); ?>
                    <img src="<?php echo isset($image['url']) ? $image['url'] : ''; ?>" alt="<?php echo isset($image['alt']) ? $image['alt'] : ''; ?>" class="img-responsive">
                </div>