本文整理匯總了PHP中Sentry::validate_user方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sentry::validate_user方法的具體用法?PHP Sentry::validate_user怎麽用?PHP Sentry::validate_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sentry
的用法示例。
在下文中一共展示了Sentry::validate_user方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: action_sign_in
public function action_sign_in()
{
$user = Session::get('oauth.user');
$client = Session::get('oauth.client');
// Check if user is signed in, if so redirect them on to /authorise
if ($user && $client) {
Response::redirect('oauth/authorise');
}
// Check there is are client parameters are stored
if ($client === NULL) {
$this->_fail('invalid_request', 'No client details have been saved. Have you deleted your cookies?', NULL, array(), 400);
return;
}
// Errors
$vars = array('error' => FALSE, 'error_messages' => array(), 'client_name' => $client->name);
// If the form has been posted
if (Input::post('validate_user')) {
$u = trim(Input::post('username'));
$p = trim(Input::post('password'));
// Validate username and password
if ($u === FALSE || empty($u)) {
$vars['error_messages'][] = 'The username field should not be empty';
$vars['error'] = TRUE;
}
if ($p === FALSE || empty($p)) {
$vars['error_messages'][] = 'The password field should not be empty';
$vars['error'] = TRUE;
}
// Check login and get credentials
if ($vars['error'] === FALSE) {
$user = Sentry::validate_user($u, $p, 'password');
if ($user === FALSE) {
$vars['error_messages'][] = 'Invalid username and/or password';
$vars['error'] = TRUE;
} else {
Session::set('oauth.user', (object) array('id' => $user->id, 'username' => $user->username, 'email' => $user->email, 'non_ad_user' => TRUE));
}
}
// If there is no error then the user has successfully signed in
if ($vars['error'] === FALSE) {
Response::redirect('oauth/authorise');
}
}
$this->template->body = View::forge('oauth/sign_in', $vars);
}