本文整理汇总了PHP中Csrf::isTokenValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Csrf::isTokenValid方法的具体用法?PHP Csrf::isTokenValid怎么用?PHP Csrf::isTokenValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Csrf
的用法示例。
在下文中一共展示了Csrf::isTokenValid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* The login action, when you do login/login
*/
public function login()
{
// check if csrf token is valid
if (!Csrf::isTokenValid()) {
LoginModel::logout();
Redirect::home();
exit;
}
// perform the login method, put result (true or false) into $login_successful
$login_successful = LoginModel::login(Request::post('user_name'), Request::post('user_password'), Request::post('set_remember_me_cookie'));
// check login status: if true, then redirect user to user/index, if false, then to login form again
if ($login_successful) {
if (Request::post('redirect')) {
Redirect::toPreviousViewedPageAfterLogin(ltrim(urldecode(Request::post('redirect')), '/'));
} else {
Redirect::to('user/index');
}
} else {
if (Request::post('redirect')) {
Redirect::to('login?redirect=' . ltrim(urlencode(Request::post('redirect')), '/'));
} else {
Redirect::to('login/index');
}
}
}
示例2: editUsername_action
/**
* Edit user name (perform the real action after form has been submitted)
*/
public function editUsername_action()
{
// check if csrf token is valid
if (!Csrf::isTokenValid()) {
LoginModel::logout();
Redirect::home();
exit;
}
UserModel::editUserName(Request::post('user_name'));
Redirect::to('user/editUsername');
}
示例3: login
public function login()
{
if (!Csrf::isTokenValid()) {
self::logout();
}
$success = LoginModel::login(Request::post('user_name'), Request::post('user_password'), Request::post('set_remember_me_cookie'));
// check login status: if true, then redirect user login/showProfile, if false, then to login form again
if ($success) {
if (Request::post('redirect')) {
Redirect::to(ltrim(urldecode(Request::post('redirect')), '/'));
} else {
Redirect::to('login/showProfile');
}
} else {
Redirect::to('login/index');
}
}
示例4: ajaxLogin
public function ajaxLogin()
{
if (!Csrf::isTokenValid()) {
LoginModel::logout();
echo 'NT';
return;
}
openssl_private_decrypt(base64_decode(Request::get_post('password')), $password, Session::get('RSA_private'));
$login_successful = LoginModel::login(Request::get_post('username'), $password, Request::get_post('remember_me'));
if ($login_successful) {
if ($redirect = Request::get_post('redirect')) {
echo ltrim(urldecode($redirect), '/');
} else {
echo Config::get('URL') . '/account';
}
} else {
echo 'N';
}
}
示例5: editUsername_action
/**
* Edit user name (perform the real action after form has been submitted)
* Auth::checkAuthentication() makes sure that only logged in users can use this action
*/
public function editUsername_action()
{
Auth::checkAuthentication();
// check if csrf token is valid
if (!Csrf::isTokenValid()) {
self::logout();
}
UserModel::editUserName(Request::post('user_name'));
Redirect::to('login/index');
}