示例#1
0
 public function onRun()
 {
     $this->logged_in = (int) Auth::logged_in();
     if ($this->property('redirect_logout') && $this->logged_in == 0) {
         return Redirect::to($this->property('redirect_logout'));
     }
     if ($this->property('redirect_login') && $this->logged_in == 1) {
         return Redirect::to($this->property('redirect_login'));
     }
     $this->wp_user = Auth::wp_get_current_user();
     if ($this->wp_user->data) {
         $this->page['user'] = $this->wp_user->to_array();
     } else {
         $this->page['user'] = false;
     }
 }
示例#2
0
 /**
  * Ajax handler
  * 
  */
 public function onSubmit()
 {
     $post = post();
     if (empty($post['type'])) {
         return false;
     }
     // Check type
     switch ($post['type']) {
         case 'register':
             // Validate input
             $validation = Validator::make($post, $this->register_rules, $this->messages);
             if ($validation->fails()) {
                 return array('errors' => $validation->errors()->toArray());
             }
             // Register the user
             $check = Auth::register($post, (bool) $this->property('email_verfication'));
             if (isset($check['errors'])) {
                 return $check;
             }
             return true;
             break;
         case 'login':
             // Validate input
             $validation = Validator::make($post, $this->login_rules, $this->messages);
             if ($validation->fails()) {
                 return array('errors' => $validation->errors()->toArray());
             }
             $creds = array('user_login' => $post['username'], 'user_password' => $post['password']);
             if (isset($post['remember_me'])) {
                 $check = Auth::login($creds, true);
             } else {
                 $check = Auth::login($creds);
             }
             if (isset($check['errors'])) {
                 return $check;
             } else {
                 return Redirect::to($this->property('redirect_login'));
             }
             break;
     }
     return false;
 }
 public function onRun()
 {
     $get = get();
     if (isset($get['key'])) {
         // Attempt to load the user by the key
         $user = Auth::get_users(array('meta_key' => '_recovery_key', 'meta_value' => $get['key']));
         if (!$user) {
             return Redirect::to($this->property('404_page'));
         }
     }
     $this->addJs('/plugins/winterpk/wordpress/assets/global/js/global.js');
     $this->addCss('/plugins/winterpk/wordpress/assets/global/css/global.css');
     $this->addJs('/plugins/winterpk/wordpress/assets/passwordrecovery/js/password-recovery.js');
     $this->addCss('/plugins/winterpk/wordpress/assets/passwordrecovery/css/password-recovery.css');
 }