当前位置: 首页>>代码示例>>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;未经允许,请勿转载。