update: fix user generate

This commit is contained in:
tokumeikoi 2021-10-06 00:20:28 +08:00
parent a6d5a433b0
commit b40272a8fa
4 changed files with 25 additions and 2 deletions

View File

@ -7,6 +7,7 @@ use App\Services\TelegramService;
use Illuminate\Http\Request;
use App\Utils\Dict;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Mail;
class ConfigController extends Controller
{
@ -32,6 +33,25 @@ class ConfigController extends Controller
]);
}
public function testSendEmail(Request $request)
{
$email = $request->session()->get('email');
$subject = 'Test Message';
try {
Mail::raw(
'Test Message',
function ($message) use ($email, $subject) {
$message->to($email)->subject($subject);
}
);
} catch (\Exception $e) {
abort(500, $e->getMessage());
}
return response([
'data' => true
]);
}
public function setTelegramWebhook(Request $request)
{
$telegramService = new TelegramService($request->input('telegram_bot_token'));

View File

@ -179,6 +179,9 @@ class UserController extends Controller
'uuid' => Helper::guid(true),
'token' => Helper::guid()
];
if (User::where('email', $user['email'])->first()) {
abort(500, '邮箱已存在于系统中');
}
$user['password'] = password_hash($request->input('password') ?? $user['email'], PASSWORD_DEFAULT);
if (!User::create($user)) {
abort(500, '生成失败');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long