當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Csrf::isTokenValid方法代碼示例

本文整理匯總了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');
         }
     }
 }
開發者ID:panique,項目名稱:huge,代碼行數:28,代碼來源:LoginController.php

示例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');
 }
開發者ID:AstroTheCoder,項目名稱:huge,代碼行數:14,代碼來源:UserController.php

示例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');
     }
 }
開發者ID:scienide00,項目名稱:WebDev_ConferenceScheduler,代碼行數:17,代碼來源:LoginController.php

示例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';
     }
 }
開發者ID:heyjohnnyfunt,項目名稱:sendashare,代碼行數:19,代碼來源:LoginController.php

示例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');
 }
開發者ID:JavierTavera,項目名稱:huge,代碼行數:14,代碼來源:LoginController.php


注:本文中的Csrf::isTokenValid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。