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


PHP Flight::users方法代碼示例

本文整理匯總了PHP中Flight::users方法的典型用法代碼示例。如果您正苦於以下問題:PHP Flight::users方法的具體用法?PHP Flight::users怎麽用?PHP Flight::users使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Flight的用法示例。


在下文中一共展示了Flight::users方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: saveProfile

 /**
  * Save properties of the user profile
  * @return [JSON] Success or error message
  */
 public static function saveProfile()
 {
     if (!Flight::has('currentUser')) {
         Flight::json(['Error' => 'No Access']);
     }
     $currentUser = Flight::get('currentUser');
     if (isset(Flight::request()->query->bio)) {
         $currentUser->bio = Flight::request()->data->bio;
     } else {
         if (isset(Flight::request()->query->password)) {
             if (!isset(Flight::request()->data->passwordold) || !isset(Flight::request()->data->passwordnew1) || !isset(Flight::request()->data->passwordnew2)) {
                 Flight::json(['success' => false, 'exception' => 'Empty fields']);
             }
             if ($currentUser->password === hash("sha256", Flight::request()->data->passwordold)) {
                 if (Flight::request()->data->passwordnew1 == Flight::request()->data->passwordnew2) {
                     $currentUser->password = hash("sha256", Flight::request()->data->passwordnew1);
                 } else {
                     Flight::json(['success' => false, 'exception' => 'New passwords are not the same']);
                 }
             } else {
                 Flight::json(['success' => false, 'exception' => 'Old password is not correct ']);
             }
         }
     }
     $result = $currentUser->update();
     if ($result != false) {
         $_SESSION['user'] = Flight::users()->getUserWithId(Flight::get('currentUser')->id);
         Flight::json(['success' => true]);
     } else {
         Flight::json(['sucess' => false, 'exception' => 'An error']);
     }
 }
開發者ID:happyoniens,項目名稱:Blog,代碼行數:36,代碼來源:userController.php

示例2: showUserSettings

 public function showUserSettings($id)
 {
     if ($id == null) {
         Flight::auth()->check();
         $user = Flight::auth()->currentUser;
     } else {
         Flight::auth()->check(20);
         $user = Flight::users()->getUserWithId($id);
     }
     Flight::util()->render('editUser', array("teams" => Flight::teams()->getAllTeams(), "user" => $user));
 }
開發者ID:happyoniens,項目名稱:Club,代碼行數:11,代碼來源:userController.php

示例3: author

 public static function author($id = null)
 {
     if ($id == null) {
         if (Flight::has('currentUser')) {
             $user = Flight::get('currentUser');
         } else {
             Flight::redirect("/");
         }
     } else {
         $user = Flight::users()->getUserWithId($id);
     }
     Flight::util()->render('profile', ['user' => $user]);
 }
開發者ID:happyoniens,項目名稱:Blog,代碼行數:13,代碼來源:viewController.php

示例4: login

 /**
  * Login with email and password
  */
 public static function login()
 {
     $email = Flight::request()->data->email;
     $password = Flight::request()->data->password;
     $user = Flight::users()->getUserWithEmail($email);
     if ($user == false) {
         Flight::util()->render('login', ['error' => 'login']);
     } else {
         if (hash("sha256", $password) == $user->password) {
             $_SESSION['user'] = $user;
             Flight::redirect("/");
         } else {
             Flight::util()->render('login', ['error' => 'login']);
         }
     }
 }
開發者ID:happyoniens,項目名稱:Blog,代碼行數:19,代碼來源:authController.php


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