User.php
1.4 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
51
52
53
54
55
56
57
58
<?php
namespace app\run\controller;
use app\common\controller\Frontend;
use think\Db;
use app\common\model\Attachment;
use think\Config;
use think\Cookie;
use think\Hook;
use think\Session;
use think\Validate;
class User extends Frontend
{
protected $noNeedLogin = ['login'];
protected $noNeedRight = '*';
protected $layout = '';
public function _initialize()
{
parent::_initialize();
}
/**
* 会员登录
*/
public function login()
{
$url = $this->request->domain().'/run/home';
if ($this->auth->id) {
$this->redirect($url);
//$this->success(__('You\'ve logged in, do not login again'), $url ? $url : url('user/index'));
}
$this->view->assign('url', $url);
$this->view->assign('title', __('Login'));
return $this->view->fetch();
}
public function logout()
{
if ($this->request->isPost()) {
$this->token();
//退出本站
$this->auth->logout();
$this->redirect('user/login');
//$this->success(__('Logout successful'), url('user/index'));
}
$html = "<form id='logout_submit' name='logout_submit' action='' method='post'>" . token() . "<input type='submit' value='ok' style='display:none;'></form>";
$html .= "<script>document.forms['logout_submit'].submit();</script>";
return $html;
}
}