Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Apr 7, 2022
1 parent f01f5d7 commit 2918c55
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 34 deletions.
16 changes: 9 additions & 7 deletions app/Http/Controllers/Api/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,23 +616,25 @@ public function email__verification()
if (empty($res)) {
return Base::retError('无效连接,请重新注册');
}

// 如果已经校验过
if (intval($res->status) === 1)
return Base::retError('链接已经使用过',['code' => 2]);
return Base::retError('链接已经使用过', ['code' => 2]);

$oldTime = Carbon::parse($res->created_at)->timestamp;
$time = Base::Time();
//24个小时失效
if (abs($time - $oldTime) > 86400) {

// 30分钟失效
if (abs($time - $oldTime) > 1800) {
return Base::retError("链接已失效,请重新登录/注册");
}
UserEmailVerification::whereCode($data['code'])
->update([
'status' => 1
]);
UserEmailVerification::whereCode($data['code'])->update([
'status' => 1
]);
User::whereUserid($res->userid)->update([
'email_verity' => 1
]);

return Base::retSuccess('绑定邮箱成功');
}
}
6 changes: 3 additions & 3 deletions app/Models/UserEmailVerification.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class UserEmailVerification extends AbstractModel
*/
public static function userEmailSend(User $user)
{
$res = self::whereUserid($user->userid)->where('created_at', '>', Carbon::now()->subMinutes(1440))->first();
$res = self::whereUserid($user->userid)->where('created_at', '>', Carbon::now()->subMinutes(30))->first();
if ($res) return;
//删除
self::whereUserid($user->userid)->delete();
Expand All @@ -53,12 +53,12 @@ public static function userEmailSend(User $user)

$setting = Base::setting('emailSetting');
$url = Base::fillUrl('single/valid/email') . '?code=' . $userEmailVerification->code;
$subject = "绑定邮箱验证";
$content = "您好,您正在绑定 " . env('APP_NAME') . " 的邮箱,请于24小时之内点击该链接完成验证 :<div style='display: flex; justify-content: center;'><a href='{$url}' target='_blank'>{$url}</a></div>";
try {
if (!Base::isEmail($user->email)) {
throw new \Exception("User email '{$user->email}' address error");
}
$subject = env('APP_NAME') . " 绑定邮箱验证";
$content = "<p>{$user->nickname} 您好,您正在绑定 " . env('APP_NAME') . " 的邮箱,请于30分钟之内点击以下链接完成验证 :</p><p style='display: flex; justify-content: center;'><a href='{$url}' target='_blank'>{$url}</a></p>";
Factory::mailer()
->setDsn("smtp://{$setting['account']}:{$setting['password']}@{$setting['smtp_server']}:{$setting['port']}?verify_peer=0")
->setMessage(EmailMessage::create()
Expand Down
22 changes: 11 additions & 11 deletions app/Tasks/OverdueRemindEmailTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function start()
ProjectTask::whereNull('complete_at')
->whereNull('archived_at')
->whereBetween("end_at", [
Carbon::now()->addMinutes($hours * 60 - 3),
Carbon::now()->addMinutes($hours * 60 + 3)
Carbon::now()->addMinutes($hours * 60),
Carbon::now()->addMinutes($hours * 60 + 10)
])->chunkById(100, function ($tasks) {
/** @var ProjectTask $task */
foreach ($tasks as $task) {
Expand All @@ -42,8 +42,8 @@ public function start()
ProjectTask::whereNull('complete_at')
->whereNull('archived_at')
->whereBetween("end_at", [
Carbon::now()->addMinutes($hours2 * 60 + 3),
Carbon::now()->addMinutes($hours2 * 60 - 3)
Carbon::now()->subMinutes($hours2 * 60 + 10),
Carbon::now()->subMinutes($hours2 * 60)
])->chunkById(100, function ($tasks) {
/** @var ProjectTask $task */
foreach ($tasks as $task) {
Expand Down Expand Up @@ -74,13 +74,6 @@ private function overdueBeforeAfterEmail(ProjectTask $task, $isBefore)
$setting = Base::setting('emailSetting');
$hours = floatval($setting['task_remind_hours']);
$hours2 = floatval($setting['task_remind_hours2']);
if ($isBefore) {
$subject = "任务提醒";
$content = "<p>用户您好, " . env('APP_NAME') . " 任务到期提醒。</p><p>您有一个任务【{$task->name}】还有{$hours}小时即将超时,请及时处理</p>";
} else {
$subject = "任务过期提醒";
$content = "<p>用户您好, " . env('APP_NAME') . " 任务到期提醒。</p><p>您的任务【{$task->name}】已经超时{$hours2}小时,请及时处理</p>";
}

/** @var User $user */
foreach ($users as $user) {
Expand All @@ -97,6 +90,13 @@ private function overdueBeforeAfterEmail(ProjectTask $task, $isBefore)
if (!Base::isEmail($user->email)) {
throw new \Exception("User email '{$user->email}' address error");
}
if ($isBefore) {
$subject = env('APP_NAME') . " 任务提醒";
$content = "<p>{$user->nickname} 您好:</p><p>您有一个任务【{$task->name}】还有{$hours}小时即将超时,请及时处理。</p>";
} else {
$subject = env('APP_NAME') . " 任务过期提醒";
$content = "<p>{$user->nickname} 您好:</p><p>您的任务【{$task->name}】已经超时{$hours2}小时,请及时处理。</p>";
}
Factory::mailer()
->setDsn("smtp://{$setting['account']}:{$setting['password']}@{$setting['smtp_server']}:{$setting['port']}?verify_peer=0")
->setMessage(EmailMessage::create()
Expand Down
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/js/build/103.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/js/build/115.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion public/js/build/127.js

This file was deleted.

2 changes: 1 addition & 1 deletion public/js/build/564.js → public/js/build/185.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/js/build/643.js → public/js/build/256.js

Large diffs are not rendered by default.

File renamed without changes.
2 changes: 1 addition & 1 deletion public/js/build/425.js → public/js/build/347.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/build/637.js

Large diffs are not rendered by default.

Loading

0 comments on commit 2918c55

Please sign in to comment.