diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 6cae12ade..26454ae85 100755 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -1074,7 +1074,7 @@ class UsersController extends AbstractController * @apiGroup users * @apiName delete__account * - * @apiParam {String} email 账号邮箱 + * @apiParam {String} email 帐号邮箱 * @apiParam {String} code 邮箱验证码 * @apiParam {String} reason 注销理由 * @apiParam {String} password 登录密码 diff --git a/app/Models/UserDelete.php b/app/Models/UserDelete.php index f9c393716..8a2edad94 100644 --- a/app/Models/UserDelete.php +++ b/app/Models/UserDelete.php @@ -9,7 +9,7 @@ namespace App\Models; * * @property int $id * @property int|null $userid 用户id - * @property string|null $email 邮箱账号 + * @property string|null $email 邮箱帐号 * @property string|null $reason 注销原因 * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at diff --git a/app/Models/UserEmailVerification.php b/app/Models/UserEmailVerification.php index 1dff69259..8f98cfffd 100644 --- a/app/Models/UserEmailVerification.php +++ b/app/Models/UserEmailVerification.php @@ -43,35 +43,39 @@ class UserEmailVerification extends AbstractModel */ public static function userEmailSend(User $user, $type = 1, $email = null) { - $email = $type != 1 ? $email : $user->email; + $email = $type == 1 ? $user->email : $email; $res = self::whereEmail($email)->where('created_at', '>', Carbon::now()->subMinutes(30))->whereType($type)->first(); if ($res) return; //删除 self::whereUserid($email)->delete(); - $code = $type != 1 ? rand(100000, 999999) : Base::generatePassword(64); - $userEmailVerification = self::createInstance([ + $code = $type == 1 ? Base::generatePassword(64) : rand(100000, 999999); + $row = self::createInstance([ 'userid' => $user->userid, 'email' => $email, 'code' => $code, 'status' => 0, 'type' => $type ]); - $userEmailVerification->save(); + $row->save(); $setting = Base::setting('emailSetting'); - $url = Base::fillUrl('single/valid/email') . '?code=' . $userEmailVerification->code; try { if (!Base::isEmail($email)) { throw new \Exception("User email '{$email}' address error"); } - if ($type == 2) { - $subject = env('APP_NAME') . "修改邮箱验证"; - $content = "
{$user->nickname} 您好,您正在修改 " . env('APP_NAME') . " 的邮箱,验证码如下。请在30分钟内输入验证码
$code
如果不是本人操作,您的账号可能存在风险,请及时修改密码!
"; - } elseif ($type == 3) { - $subject = env('APP_NAME') . "注销账号验证"; - $content = "{$user->nickname} 您好,您正在注销 " . env('APP_NAME') . " 的账号,验证码如下。请在30分钟内输入验证码
$code
如果不是本人操作,您的账号可能存在风险,请及时修改密码!
"; - } else { - $subject = env('APP_NAME') . "绑定邮箱验证"; - $content = "{$user->nickname} 您好,您正在绑定 " . env('APP_NAME') . " 的邮箱,请于30分钟之内点击以下链接完成验证 :
"; + switch ($type) { + case 2: + $subject = env('APP_NAME') . "修改邮箱验证"; + $content = "{$user->nickname} 您好,您正在修改 " . env('APP_NAME') . " 的邮箱,验证码如下。请在30分钟内输入验证码
$code
如果不是本人操作,您的帐号可能存在风险,请及时修改密码!
"; + break; + case 3: + $subject = env('APP_NAME') . "注销帐号验证"; + $content = "{$user->nickname} 您好,您正在注销 " . env('APP_NAME') . " 的帐号,验证码如下。请在30分钟内输入验证码
$code
如果不是本人操作,您的帐号可能存在风险,请及时修改密码!
"; + break; + default: + $url = Base::fillUrl('single/valid/email') . '?code=' . $row->code; + $subject = env('APP_NAME') . "绑定邮箱验证"; + $content = "{$user->nickname} 您好,您正在绑定 " . env('APP_NAME') . " 的邮箱,请于30分钟之内点击以下链接完成验证 :
"; + break; } Factory::mailer() ->setDsn("smtp://{$setting['account']}:{$setting['password']}@{$setting['smtp_server']}:{$setting['port']}?verify_peer=0") diff --git a/database/migrations/2022_07_13_145504_create_user_deletes_table.php b/database/migrations/2022_07_13_145504_create_user_deletes_table.php index c4cbb9e70..04af201c8 100644 --- a/database/migrations/2022_07_13_145504_create_user_deletes_table.php +++ b/database/migrations/2022_07_13_145504_create_user_deletes_table.php @@ -16,7 +16,7 @@ class CreateUserDeletesTable extends Migration Schema::create('user_deletes', function (Blueprint $table) { $table->bigIncrements('id'); $table->bigInteger('userid')->nullable()->default(0)->comment('用户id'); - $table->string('email', 100)->nullable()->default('')->comment('邮箱账号'); + $table->string('email', 100)->nullable()->default('')->comment('邮箱帐号'); $table->text('reason')->nullable()->comment('注销原因'); $table->timestamps(); }); diff --git a/resources/assets/js/pages/manage/setting/components/SystemEmailSetting.vue b/resources/assets/js/pages/manage/setting/components/SystemEmailSetting.vue index 978831e41..0a886d497 100644 --- a/resources/assets/js/pages/manage/setting/components/SystemEmailSetting.vue +++ b/resources/assets/js/pages/manage/setting/components/SystemEmailSetting.vue @@ -32,7 +32,7 @@