Exemple #1
0
 /**
  * This method will be called after we route to the destinated method
  * 
  * @access	public
  */
 public function before()
 {
     $this->language = \Hybrid\Factory::get_language();
     $this->user = \Hybrid\Acl_User::get();
     \Event::trigger('controller_before');
     return parent::before();
 }
Exemple #2
0
 public function post_login()
 {
     $username = \Input::post('username');
     $password = \Input::post('password');
     $result = \Hybrid\Acl_User::login($username, $password);
     if (false === $result) {
         $this->response(array('text' => 'Invalid username and password combination'), 401);
     } else {
         $this->response(array('text' => 'Login successful, redirecting now...', 'redirect' => \Uri::create('account/me')), 200);
     }
 }
Exemple #3
0
 /**
  * This method will be called after we route to the destinated method
  * 
  * @access	public
  */
 public function before()
 {
     $this->language = \Hybrid\Factory::get_language();
     $this->user = \Hybrid\Acl_User::get();
     \Event::trigger('controller_before');
     if (\Hybrid\Request::main() !== \Hybrid\Request::active()) {
         $this->set_content_type = false;
     }
     \Hybrid\Restful::auth();
     return parent::before();
 }
Exemple #4
0
 /**
  * Check if user has any of provided roles (however this should be in \Hybrid\User IMHO)
  * 
  * @static
  * @access	public
  * @param	mixed	$check_roles
  * @return	bool 
  */
 public static function has_roles($check_roles)
 {
     $user = \Hybrid\Acl_User::get();
     if (!is_array($check_roles)) {
         $check_roles = array($check_roles);
     }
     foreach ($user->roles as $role) {
         $role = \Inflector::friendly_title($role, '-', TRUE);
         foreach ($check_roles as $check_against) {
             if ($role == $check_against) {
                 return true;
             }
         }
     }
     return false;
 }