forked from whcyc2002/swoole_framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.php
More file actions
50 lines (46 loc) · 1.04 KB
/
User.php
File metadata and controls
50 lines (46 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace App\Controller;
use Swoole;
class User extends Swoole\Controller
{
function login()
{
//使用crypt密码
Swoole\Auth::$password_hash = Swoole\Auth::HASH_CRYPT;
$this->session->start();
//已经登录了,跳转到
if ($this->user->isLogin())
{
$this->http->redirect('/user/home/');
return;
}
if (!empty($_POST['password']))
{
$r = $this->user->login(trim($_POST['username']), $_POST['password']);
if ($r)
{
$this->http->redirect('/user/home/');
return;
}
else
{
echo "登录失败";
}
}
else
{
$this->display('user/login.php');
}
}
function home()
{
$this->session->start();
var_dump($_SESSION);
Swoole\Auth::loginRequire();
}
function logout()
{
$this->session->start();
$this->user->logout();
}
}