登陆来路refer中间件跳转修复
This commit is contained in:
parent
03a46291c6
commit
6238334e13
@ -12,27 +12,28 @@ use think\facade\Cookie;
|
||||
use think\facade\Cache;
|
||||
use think\facade\View;
|
||||
use app\common\model\User;
|
||||
use taoler\com\Message;
|
||||
use app\event\UserLogin;
|
||||
|
||||
class Login extends BaseController
|
||||
{
|
||||
//已登陆检测
|
||||
protected $middleware = ['logedcheck'];
|
||||
protected $middleware = [
|
||||
'logedcheck' => ['except' => ['index'] ]
|
||||
];
|
||||
|
||||
//用户登陆
|
||||
public function index()
|
||||
{
|
||||
//已登陆跳出
|
||||
if(Session::has('user_id')){
|
||||
return redirect((string) url('user/index'));
|
||||
}
|
||||
//获取登录前访问页面refer
|
||||
$refer = Request::server('HTTP_REFERER');
|
||||
$domain = Request::domain();
|
||||
//$domain = Request::domain();
|
||||
//截取域名后面的字符
|
||||
$url = substr($refer,strlen($domain));
|
||||
if(empty($url)){
|
||||
$url = '/';
|
||||
}
|
||||
Cookie::set('url',$url);
|
||||
|
||||
//$url = substr($refer,strlen($domain));
|
||||
Cookie::set('url',$refer);
|
||||
if(Request::isAjax()) {
|
||||
//登陆前数据校验
|
||||
$data = Request::param();
|
||||
@ -72,7 +73,6 @@ class Login extends BaseController
|
||||
//登陆成功
|
||||
$ip = request()->ip();
|
||||
$name = $data['name'];
|
||||
|
||||
//时间更新ip和日志
|
||||
event(new UserLogin($name,$ip));
|
||||
|
||||
|
@ -9,7 +9,7 @@ class LogedCheck
|
||||
{
|
||||
//已登陆跳出
|
||||
if(Session::has('user_id')){
|
||||
return redirect('/index/user/index');
|
||||
return redirect((string) url('user/index'));
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
{/volist}
|
||||
<li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>
|
||||
{if session('?user_id')}
|
||||
<li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{:url('user/post')}">{:lang('add_post')}</a></li>
|
||||
<li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{:url('user/post')}">{:lang('add post')}</a></li>
|
||||
<li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{:url('user/post#collection')}">{:lang('my collection')}</a></li>
|
||||
{/if}
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user