This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 30th, 2012  |  syntax: None  |  size: 1.12 KB  |  views: 41  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php defined('SYSPATH') or die('No direct access allowed.');
  2. /**
  3.  * Default auth user
  4.  *
  5.  * @package    Kohana/Auth
  6.  * @author     Kohana Team
  7.  * @copyright  (c) 2007-2011 Kohana Team
  8.  * @license    http://kohanaframework.org/license
  9.  */
  10. class Model_User extends AutoModeler_ORM {
  11.         /**
  12.          * A user has many tokens and roles
  13.          *
  14.          * @var array Relationhips
  15.          */
  16.         protected $_has_many = array(
  17.                 'user_tokens' => array('model' => 'user_token'),
  18.                 'roles'       => array('model' => 'role', 'through' => 'roles_users'),
  19.         );
  20.  
  21.         protected $_table_name = 'users';
  22.  
  23.         protected $_data = array('id' => '',
  24.                 'username' => '',
  25.                 'password' => '',
  26.                 'email' => '',
  27.                 'last_login' => '',
  28.                 'logins' => '');
  29.  
  30.         protected $_rules = array(
  31.                 'username' => array(
  32.                         array('not_empty'),
  33.                 ),
  34.                 'email' => array(
  35.                         array('email'),
  36.                 )
  37.         );
  38.  
  39.         /**
  40.          * overload __set() to hash a password
  41.          *
  42.          * @return string
  43.          */
  44.         public function __set($key, $value)
  45.         {
  46.                 if ($key == 'password')
  47.                 {
  48.                         $this->_data[$key] = sha1($value);
  49.                         return;
  50.                 }
  51.  
  52.                 return parent::__set($key, $value);
  53.         }
  54. } // End User Model User Model
clone this paste RAW Paste Data