xieruidong 2 anos atrás
pai
commit
d449111a1c
3 arquivos alterados com 346 adições e 167 exclusões
  1. 1 1
      application/api/controller/Ems.php
  2. 34 0
      application/api/controller/User.php
  3. 311 166
      public/api.html

+ 1 - 1
application/api/controller/Ems.php

@@ -25,7 +25,7 @@ class Ems extends Api
      *
      * @ApiMethod (POST)
      * @param string $email 邮箱
-     * @param string $event 事件名称
+     * @param string $event 事件名称changeemail更换邮箱注册register更改密码changepwdi重置密码resetpwd
      */
     public function send()
     {

+ 34 - 0
application/api/controller/User.php

@@ -532,4 +532,38 @@ class User extends Api
         Sms::flush($mobile, 'changemobile');
         $this->success();
     }
+    /**
+     * 修改邮箱
+     *
+     * @ApiMethod (POST)
+     * @param string $email   邮箱
+     * @param string $captcha 验证码
+     */
+    public function changeemail()
+    {
+        $user = $this->auth->getUser();
+        $email = $this->request->post('email');
+        $captcha = $this->request->post('captcha');
+        if (!$email || !$captcha) {
+            $this->error(__('Invalid parameters'));
+        }
+        if (!Validate::is($email, "email")) {
+            $this->error(__('Email is incorrect'));
+        }
+        if (\app\common\model\User::where('email', $email)->where('id', '<>', $user->id)->find()) {
+            $this->error(__('Email already exists'));
+        }
+        $result = Ems::check($email, $captcha, 'changeemail');
+        if (!$result) {
+            $this->error(__('Captcha is incorrect'));
+        }
+        $verification = $user->verification;
+        $verification->email = 1;
+        $user->verification = $verification;
+        $user->email = $email;
+        $user->save();
+
+        Ems::flush($email, 'changeemail');
+        $this->success();
+    }
 }

Diferenças do arquivo suprimidas por serem muito extensas
+ 311 - 166
public/api.html


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff