Ejemplo n.º 1
0
 public static function setSeccode($name, $value, $ttl = 1800)
 {
     cookie("seccode_{$name}", auth::encode($value), $ttl);
 }
Ejemplo n.º 2
0
 /**
  * reset user's password
  *
  * @return void
  * @author Andy Bennett
  */
 public function forgotten_credential_reset()
 {
     try {
         $segs = array_reverse(URI::instance()->segment_array());
         $code = $segs[0];
         $id = $segs[1];
         // check the passed values
         if (!is_numeric($id) or $id <= 0) {
             throw new Exception("auth.invalid_user_id");
         }
         if (!strlen($code) or !preg_match('/[a-zA-Z0-9]+/', $code)) {
             throw new Exception('auth.invalid_forgotten_code');
         }
         $user = ORM::factory('user')->where(array('id' => $id, 'activated' => 1, 'forgotten_credential_code' => $code))->find();
         if (!$user->loaded) {
             throw new Exception("auth.invalid_user");
         }
         // if they do, generate a new credential
         $conf = Kohana::config('steamauth.steamauth');
         $credential = auth::generate_random_string($conf->user_credential_min, $conf->user_credential_max);
         //encrypts the random credential using the md5 encryption
         $user->credential = auth::encode($credential);
         $user->save();
         // inform the user of their new credential
         $email_data = array('user' => $user, 'credential' => $credential);
         Event::run('steamauth.forgotten_credential_reset', $email_data);
     } catch (Exception $e) {
         Event::run('steamauth.forgotten_credential_reset_error', $error = $e->getMessage());
     }
 }