本文整理汇总了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']);
}
}
示例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));
}
示例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]);
}
示例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']);
}
}
}