Ejemplo n.º 1
0
 public function save()
 {
     if (array_key_exists($this->_columns['password'], $this->_changed)) {
         $this->_object[$this->_columns['password']] = A1::instance($this->_config)->hash_password($this->_object[$this->_columns['password']]);
     }
     return parent::save();
 }
Ejemplo n.º 2
0
 function f()
 {
     A1::f();
     A2::f();
     \A1::f();
     \A2::f();
     B::f();
     C::f();
 }
 function f()
 {
     self::nonStaticButSelfClass();
     static::nonStaticButSelfClass();
     parent::nonStaticButSelfClass();
     P::nonStaticAClass();
     P::staticAClass();
     A1::nonStaticButSelfClass();
     \a1::nonStaticButSelfClass();
     b::nonStaticButSelfClass();
 }
Ejemplo n.º 4
0
 public function __set($key, $value)
 {
     if ($key === $this->columns['password']) {
         if ($this->loaded and $value === '') {
             // Do not set empty passwords
             return;
         }
         // Use Auth to hash the password
         $value = A1::instance($this->config_name)->hash_password($value);
     }
     parent::__set($key, $value);
 }
Ejemplo n.º 5
0
 public function before()
 {
     if ($this->request->method() == HTTP_Request::OPTIONS) {
         $this->request->action('options');
     }
     $action = $this->request->action();
     if ($action and !in_array($action, array('index', 'authorize'))) {
         // Only apply templating to index and authorization actions
         $this->auto_render = FALSE;
     }
     parent::before();
     $this->auth = A1::instance();
     $this->user = $this->auth->get_user();
     $this->session = $this->auth->session();
     if ($this->auto_render) {
         $this->header->set('logged_in', $this->auth->logged_in());
     }
 }
Ejemplo n.º 6
0
 public function action_register()
 {
     /*
      * Checks if the user is logged in or there is no users in the DB. Otherwise redirects
      * to a mainpage
      */
     if (!A1::instance()->logged_in() or Jelly::select('user')->count()) {
         $this->request->redirect('auth/login');
     }
     $this->template->title = __('auth.register');
     $errors = FALSE;
     $user = Jelly::factory('user');
     if ($_POST) {
         $user->set(Arr::extract($_POST, array('email', 'username', 'password', 'password_confirm')));
         $user->add('roles', 1);
         try {
             $user->save();
             $this->request->redirect();
         } catch (Validate_Exception $e) {
             $errors = $e->array->errors('auth');
         }
     }
     $this->template->content = View::factory('auth/register')->set('user', $user)->set('errors', $errors);
 }
Ejemplo n.º 7
0
 /**
  * Hash callback using the A1 library
  *
  * @param string password to hash
  * @return string
  */
 public static function hash_password($password)
 {
     return A1::instance()->hash($password);
 }
Ejemplo n.º 8
0
 /**
  * Test change in password
  */
 public function testChangePassword()
 {
     $pass = A1::instance('a1')->hash_password('test_pass');
     DB::insert('users', array('username', 'password'))->values(array('test_user', $pass))->execute();
     $user = Sprig::factory('user', array('username' => 'test_user'))->load();
     $this->assertEquals($pass, $user->password);
     $user->password = '******';
     $user->update();
     $user->load();
     // Reload hashed password
     $salt = A1::instance('a1')->find_salt($user->password);
     $changed = A1::instance('a1')->hash_password('new_pass', $salt);
     $SUT = DB::select()->from('users')->where('id', '=', $user->id)->execute()->current();
     $this->assertEquals($changed, $SUT['password']);
 }
Ejemplo n.º 9
0
Archivo: admin.php Proyecto: sars/rp
 public function before()
 {
     parent::before();
     $this->auth = A1::instance();
     $this->user = $this->auth->get_user();
 }
Ejemplo n.º 10
0
 public function doTest(A1 $obj)
 {
     echo __METHOD__ . "\n";
     $obj->test();
 }
Ejemplo n.º 11
0
 public function foo()
 {
     parent::ma2();
     b2::ma2();
 }
Ejemplo n.º 12
0
<?php

/*
 * The Authentication library to use
 * Make sure that the library supports a get_user method that returns FALSE when no user is logged in
 * and a user object that implements Acl_Role_Interface when a user is logged in.
 */
$config['a1'] = A1::instance('a1');
/*
 * The ACL Roles (String IDs are fine, use of ACL_Role_Interface objects also possible)
 * Use: ROLE => PARENT(S) (make sure parent is defined as role itself before you use it as a parent)
 */
$config['roles'] = array('user' => 'guest', 'admin' => 'user');
/*
 * The name of the guest role 
 * Used when no user is logged in.
 */
$config['guest_role'] = 'guest';
/*
 * The ACL Resources (String IDs are fine, use of ACL_Resource_Interface objects also possible)
 * Use: ROLE => PARENT (make sure parent is defined as resource itself before you use it as a parent)
 */
$config['resources'] = array('blog' => NULL);
/*
* The ACL Rules (Again, string IDs are fine, use of ACL_Role/Resource_Interface objects also possible)
* Split in allow rules and deny rules, one sub-array per rule:
    array( ROLES, RESOURCES, PRIVILEGES, ASSERTION)
*/
$config['rules'] = array('allow' => array(array('guest', 'blog', 'read'), array('user', 'blog', 'add'), array('user', 'blog', 'edit', new Acl_Assert_Argument(array('primary_key_value' => 'user_id'))), array('admin', 'blog', 'delete')), 'deny' => array());
Ejemplo n.º 13
0
// now new vars
check::globals(array(bar_x));
class PhpFoo extends Foo
{
    function ping()
    {
        return "PhpFoo::ping()";
    }
}
$a = new PhpFoo();
check::equal($a->ping(), "PhpFoo::ping()", "ping failed");
check::equal($a->pong(), "Foo::pong();PhpFoo::ping()", "pong failed");
$b = new Foo();
check::equal($b->ping(), "Foo::ping()", "ping failed");
check::equal($b->pong(), "Foo::pong();Foo::ping()", "pong failed");
$a = new A1(1);
check::equal($a->rg(2), 2, "rg failed");
class PhpClass extends MyClass
{
    function vmethod($b)
    {
        $b->x = $b->x + 31;
        return $b;
    }
}
$b = new Bar(3);
$d = new MyClass();
$c = new PhpClass();
$cc = MyClass::get_self($c);
$dd = MyClass::get_self($d);
$bc = $cc->cmethod($b);
Ejemplo n.º 14
0
 /**
  * Test logged in from cookie
  */
 public function testLoggedInFromCookie()
 {
     DB::insert('users', array('id', 'username', 'token'))->values(array(2, 'logged_in_cookie_user', 1234))->execute();
     $_COOKIE['a1_a1_autologin'] = cookie::salt('a1_a1_autologin', '1234.2') . '~1234.2';
     $this->assertType('string', cookie::get('a1_a1_autologin'));
     $result = A1::instance('a1')->logged_in();
     $this->assertTrue($result);
     $session = Session::instance(Kohana::config('a1.session_type'));
     $user = $session->get('a1_a1');
     $this->assertType('object', $user);
     $this->assertEquals('logged_in_cookie_user', $user->username);
     $this->assertEquals(2, $user->id);
 }
Ejemplo n.º 15
0
Archivo: mango.php Proyecto: ryross/A1
 public function hash($password)
 {
     return A1::instance($this->_name)->hash($password);
 }
Ejemplo n.º 16
0
 public function __construct()
 {
     $this->a1 = A1::instance();
 }
Ejemplo n.º 17
0
 /**
  * Hash callback using the A1 library
  *
  * @param   string  password to hash
  * @return  string
  */
 public function hash_password(Validate $array, $field)
 {
     $pass = $array[$field];
     $array[$field] = A1::instance($this->_config)->hash_password($pass);
 }
Ejemplo n.º 18
0
 public function filters()
 {
     return array('password' => array(array(array(A1::instance('admin/a1'), 'hash'))));
 }