本文整理汇总了PHP中auth::encode方法的典型用法代码示例。如果您正苦于以下问题:PHP auth::encode方法的具体用法?PHP auth::encode怎么用?PHP auth::encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth
的用法示例。
在下文中一共展示了auth::encode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setSeccode
public static function setSeccode($name, $value, $ttl = 1800)
{
cookie("seccode_{$name}", auth::encode($value), $ttl);
}
示例2: forgotten_credential_reset
/**
* 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());
}
}