dever 7 年 前
コミット
d2464b9c36
5 ファイル変更36 行追加28 行削除
  1. 9 2
      config/base.php
  2. 15 8
      src/Lib/Base.php
  3. 1 1
      src/Login.php
  4. 9 6
      src/Reg.php
  5. 2 11
      src/User.php

+ 9 - 2
config/base.php

@@ -1,11 +1,14 @@
 <?php
 
-return array
+# 一些基本配置
+$config['base'] = array
 (
 	# 站点使用邮箱还是手机作为主账号,如果是手机,请填写手机验证码的配置接口
 	'account' => 'email',
 	'mobileCode' => array
 	(
+		# debug模式
+		'debug' => true,
 		# 发送短信的接口
 		'url' => '',
 		# 短信签名
@@ -19,4 +22,8 @@ return array
 		# 不允许多久之内重复发送,默认为60秒
 		'time' => 60,
 	),
-);
+	# 注册成功后,调取的接口
+	'regAction' => '',
+);
+
+return $config;

+ 15 - 8
src/Lib/Base.php

@@ -60,13 +60,13 @@ class Base
             $check = Dever::load('passport/code-check', $param);
 
             if ($check) {
-                if (time() - $check['cdate'] < Dever::config('base', 'passport')->mobileCode['time']) {
+                if (time() - $check['cdate'] < Dever::config('base', 'project')->mobileCode['time']) {
                     Dever::alert('请不要在一分钟之内申请多次验证码,请您稍后再试');
                 }
             }
         }
 
-        $total = Dever::config('base', 'passport')->mobileCode['total'];
+        $total = Dever::config('base', 'project')->mobileCode['total'];
         if ($info >= $total) {
             Dever::alert('很抱歉,您已经申请获取验证码超过' . $total . '次,今天您已经无法获取验证码了,请您明天再来');
         }
@@ -82,7 +82,7 @@ class Base
 
         # 发送验证码到手机上
         //$text = '您好,您的验证码为' . $code->mcode . ',十分钟之内有效。';
-        $text = str_replace('{code}', $code->mcode, Dever::config('base', 'passport')->mobileCode['msg']);
+        $text = str_replace('{code}', $code->mcode, Dever::config('base', 'project')->mobileCode['msg']);
 
         # 启动发送
         $this->send($mobile, $text, $id);
@@ -94,12 +94,15 @@ class Base
 
     private function send($mobile, $content, $id)
     {
-        $url = Dever::config('base', 'passport')->mobileCode['url'];
+        $url = Dever::config('base', 'project')->mobileCode['url'];
 
-        if (Dever::config('base', 'passport')->mobileCode['signType'] == 1) {
-            $content = Dever::config('base', 'passport')->mobileCode['sign'] . $content;
+        if (!$url) {
+            return;
+        }
+        if (Dever::config('base', 'project')->mobileCode['signType'] == 1) {
+            $content = Dever::config('base', 'project')->mobileCode['sign'] . $content;
         } else {
-            $content .= Dever::config('base', 'passport')->mobileCode['sign'];
+            $content .= Dever::config('base', 'project')->mobileCode['sign'];
         }
 
         $param['phone'] = $mobile;
@@ -140,7 +143,7 @@ class Base
     protected function save($user)
     {
         if (is_numeric($user)) {
-            $user = Dever::load('service/company-one', $user);
+            $user = Dever::load('passport/user-one', $user);
         }
 
         if ($user && is_array($user)) {
@@ -153,6 +156,10 @@ class Base
 
             $user['signature'] = Dever::login($user['id']);
 
+            if (Dever::config('base', 'project')->regAction) {
+                Dever::load(Dever::config('base', 'project')->regAction, $user);
+            }
+
             return $user;
         }
     }

+ 1 - 1
src/Login.php

@@ -24,7 +24,7 @@ class Login extends Base
 
     public function action()
     {
-        $account = Dever::config('base', 'passport')->account;
+        $account = Dever::config('base', 'project')->account;
 
         $param['option_' . $account] = Dever::input($account);
 

+ 9 - 6
src/Reg.php

@@ -24,10 +24,12 @@ class Reg extends Base
         $mobile = $this->checkMobileExists(1);
 
         $code = $this->mcode($mobile);
-
-        //Dever::alert('验证码已发送至您的手机,请注意查收,十分钟之内有效');
-
-        return '验证码已发送至您的手机,请注意查收,十分钟之内有效:' . $code;
+        $msg = '验证码已发送至您的手机,请注意查收,十分钟之内有效';
+        $debug = Dever::config('base', 'project')->mobileCode['debug'];
+        if ($debug) {
+            $msg .= ':' . $code;
+        }
+        return $msg;
     }
 
     /**
@@ -144,7 +146,7 @@ class Reg extends Base
 
     public function action()
     {
-        $account = Dever::config('base', 'passport')->account;
+        $account = Dever::config('base', 'project')->account;
         $baccount = ucfirst($account);
         $method = 'check' . $baccount . 'Exists';
 
@@ -154,6 +156,7 @@ class Reg extends Base
             $param['add_' . $account] = $param['option_' . $account];
             $param['add_username'] = Dever::input('username');
             $param['add_password'] = Dever::input('password');
+            $param['add_sex'] = Dever::input('sex');
             $cpassword = Dever::input('cpassword');
 
             if (!$param['add_username']) {
@@ -181,7 +184,7 @@ class Reg extends Base
 
     public function forget()
     {
-        $account = Dever::config('base', 'passport')->account;
+        $account = Dever::config('base', 'project')->account;
         $baccount = ucfirst($account);
         $method = 'check' . $baccount . 'Exists';
 

+ 2 - 11
src/User.php

@@ -17,15 +17,6 @@ class User extends Base
     {
         if (!$this->user) {
             $this->user = $this->info();
-
-            $url = Dever::url();
-            if (!$this->user && (strpos($url, 'my/') !== false || strpos($url, 'forum/post') !== false)) {
-                return Dever::load('passport/login.location');
-            }
-
-            if ($this->user) {
-                $this->user['msgnum'] = 0;
-            }
         }
 
         return $this->user;
@@ -61,8 +52,8 @@ class User extends Base
             $update['set_sex'] = 1;
         } elseif ($sex == '女') {
             $update['set_sex'] = 2;
-        } else {
-            $update['set_sex'] = 0;
+        } elseif ($sex == '未知') {
+            $update['set_sex'] = 3;
         }
 
         if ($update['set_avatar']) {