File tree Expand file tree Collapse file tree 5 files changed +100
-4
lines changed
Expand file tree Collapse file tree 5 files changed +100
-4
lines changed Original file line number Diff line number Diff line change @@ -1657,4 +1657,20 @@ public function resetUserTraffic(Request $request)
16571657
16581658 return Response::json (['status ' => 'success ' , 'data ' => '' , 'message ' => '操作成功 ' ]);
16591659 }
1660+
1661+ /**
1662+ * 以某用户登录
1663+ * @param Request $req 请求
1664+ * @return JSON 响应
1665+ */
1666+ public function loginas (Request $ req ){
1667+ $ id = $ req ->user_id ;
1668+ $ user = User::find ($ id );
1669+ if (!$ user ){
1670+ return ['errcode ' =>-1 ,'errmsg ' =>"用户不存在 " ];
1671+ }
1672+ $ req ->session ()->put ('admin ' ,$ req ->session ()->get ("user " ));
1673+ $ req ->session ()->put ('user ' , $ user ->toArray ());
1674+ return ['errcode ' =>0 ,'errmsg ' =>"成功! " ];
1675+ }
16601676}
Original file line number Diff line number Diff line change @@ -952,4 +952,16 @@ public function payment(Request $req){
952952 $ v ['payment ' ] = Payment::where ("status " ,1 )->where ("user_id " ,$ req ->session ()->get ('user ' )['id ' ])->get ();
953953 return Response::view ("user.payment " ,$ v );
954954 }
955+ /**
956+ * 管理员以某用户登录后恢复到管理员权限
957+ * @param Request $req 请求
958+ * @return Response 响应
959+ */
960+ public function loginasadmin (Request $ req ){
961+ if (\Session::get ("admin " ,[]) == User::find (\Session::get ("admin " ,['id ' =>0 ])['id ' ])->toarray () ){
962+ \Session::put ('user ' ,\Session::get ("admin " ,[]));
963+ return ['errcode ' =>0 ];
964+ }
965+ return ['errcode ' =>-1 ,'errmsg ' =>"非法的请求. " ];
966+ }
955967}
Original file line number Diff line number Diff line change 2929 <div class =" col-md-6" >
3030 <!-- BEGIN SAMPLE FORM PORTLET-->
3131 <div class =" portlet light bordered" >
32- <div class =" portlet-title" >
33- <div class =" caption" >
34- <span class =" caption-subject font-dark bold uppercase" >账号信息</span >
32+ <div class =" portlet-title" style =" width :100% " >
33+ <div class =" caption" style =" width :100% " >
34+ <div class =" row" >
35+ <span class =" caption-subject font-dark bold uppercase col-md-4" >账号信息</span >
36+ <div class =" text-right col-md-8" style =" " >
37+ <a href =" #" id =" loginas" class =" badge badge-success" >以此用户登录</a >
38+ </div >
39+ </div >
3540 </div >
3641 </div >
3742 <div class =" portlet-body" >
318323 <script src =" /js/layer/layer.js" type =" text/javascript" ></script >
319324
320325 <script type =" text/javascript" >
326+ // 处理 以某客户登录
327+ $ (" #loginas" ).click (function (){
328+ $ .ajax ({
329+ ' url' : " {{ url (" /admin/loginas" )} }" ,
330+ ' data' : {
331+ ' user_id' : {{ $user -> id } } ,
332+ ' _token' : " {{ csrf_token ()} }"
333+ },
334+ ' dataType' : " json" ,
335+ ' type' : " POST" ,
336+ success : function (data ){
337+ if (data .errcode == 0 ){
338+ layer .msg (" 操作成功!" ,{time: 1000 });
339+ setTimeout (function (){
340+ window .location .href = " /user" ;
341+ },1000 );
342+ }else {
343+ layer .msg (" 操作失败!" + data .errmsg ,{time: 5000 });
344+ }
345+ }
346+ });
347+ });
321348 // 有效期
322349 $ (' .input-daterange input' ).each (function () {
323350 $ (this ).datepicker ({
@@ -385,4 +412,4 @@ function makePasswd() {
385412 });
386413 }
387414 </script >
388- @endsection
415+ @endsection
Original file line number Diff line number Diff line change 168168 <div class =" page-content-wrapper" >
169169 @yield (' content' )
170170 </div >
171+ @if (Session:: get (" admin" ) )
172+ <div class =" portlet light bordered" style =" position :fixed ;right :20px ;bottom :0px ;width :200px " >
173+ <div class =" portlet-body text-right" >
174+ <button class =" btn btn-sm btn-success" id =" return_to_admin" > 返回管理页面 </button >
175+ <h6 >您当前正在以{{ Session:: get (" user" )[' username' ] } } 用户登录,点击上面按钮返回管理页面</h6 >
176+ </div >
177+ </div >
178+ @endif
171179 <!-- END CONTENT -->
172180</div >
173181<!-- END CONTAINER -->
194202<!-- END CORE PLUGINS -->
195203<!-- BEGIN PAGE LEVEL PLUGINS -->
196204@yield (' script' )
205+
206+ @if (Session:: get (" admin" ) )
207+ <script src =" /js/layer/layer.js" type =" text/javascript" ></script >
208+ <script type =" text/javascript" >
209+ $ (" #return_to_admin" ).click (function (){
210+ $ .ajax ({
211+ ' url' : " {{ url (" /user/loginasadmin" )} }" ,
212+ ' data' : {
213+ ' _token' : " {{ csrf_token ()} }"
214+ },
215+ ' dataType' : " json" ,
216+ ' type' : " POST" ,
217+ success : function (data ){
218+ if (data .errcode == 0 ){
219+ layer .msg (" 操作成功!" ,{time: 1000 });
220+ setTimeout (function (){
221+ window .location .href = " /admin" ;
222+ },1000 );
223+ }else {
224+ layer .msg (" 操作失败!" + data .errmsg ,{time: 5000 });
225+ }
226+ },
227+ error : function (data ){
228+ layer .msg (" 操作失败!" + data,{time: 5000 });
229+ }
230+ });
231+ });
232+ </script >
233+ @endif
197234<!-- END PAGE LEVEL PLUGINS -->
198235<!-- BEGIN THEME GLOBAL SCRIPTS -->
199236<script src =" /assets/global/scripts/app.min.js" type =" text/javascript" ></script >
Original file line number Diff line number Diff line change 7474 Route::post ('coupon/delCoupon ' , 'CouponController@delCoupon ' ); // 删除优惠券
7575 Route::get ('coupon/exportCoupon ' , 'CouponController@exportCoupon ' ); // 导出优惠券
7676 Route::get ('emailLog/logList ' , 'EmailLogController@logList ' ); // 邮件发送日志
77+ Route::post ("admin/loginas " ,"AdminController@loginas " );
7778});
7879
7980Route::group (['middleware ' => ['user ' ]], function () {
100101 // payment
101102 Route::get ("user/payment " ,"UserController@payment " );
102103 Route::post ("user/payment " ,"PaymentController@new " );
104+
105+ // 返回管理员页面
106+ Route::post ("user/loginasadmin " ,"UserController@loginasadmin " );
103107});
104108Route::post ("/payment/query " ,"PaymentController@query " );
105109Route::post ("/payment/callback/{type} " ,"PaymentController@callback " );
You can’t perform that action at this time.
0 commit comments