Browse Source

feat():授权

geek 4 years ago
parent
commit
5310d22080
2 changed files with 8 additions and 9 deletions
  1. 6 7
      application/index/controller/Index.php
  2. 2 2
      application/index/controller/User.php

+ 6 - 7
application/index/controller/Index.php

@@ -17,13 +17,12 @@ class Index {
 
         $visitorId = input('visitorId');
         $notifyUrl = input('notify_url');
-        var_dump(input());
-        die();
-//        if (empty(session('unionid'))){
-//            header("Location:".CommonService::getAuthUrl());
-////            redirect(CommonService::getAuthUrl());
-//            die();
-//        }
+
+        if (empty(Session::get('wxId'))){
+            header("Location:".CommonService::getAuthUrl());
+//            redirect(CommonService::getAuthUrl());
+            die();
+        }
         //增加客户自己的验证逻辑,例如登录,关注,付费,填手机号等
         $key = md5($visitorId.CommonService::getSetData()['channel_auth_code']);
         if(strpos($notifyUrl,'?') !== false){//url参数处理,将key加到url参数中

+ 2 - 2
application/index/controller/User.php

@@ -9,6 +9,7 @@ namespace app\index\controller;
 
 use app\common\service\CommonService;
 use app\index\BaseController;
+use think\facade\Session;
 
 class User extends BaseController {
 
@@ -20,8 +21,7 @@ class User extends BaseController {
             'avatar' => input('avatar'),
             'key'    => md5(input('unionid').CommonService::getSetData()['channel_auth_code'])
         ];
-        session('unionid', input('unionid'));
-
+        Session::set('wxId',input('unionid'));
         header('Location:http://mudu.tv/activity.php?a=userAssign&'.http_build_query($params));
     }
 }