diff --git a/backend/app/Http/Controllers/Api/ChildrenController.php b/backend/app/Http/Controllers/Api/ChildrenController.php index be21046f..03f5d927 100644 --- a/backend/app/Http/Controllers/Api/ChildrenController.php +++ b/backend/app/Http/Controllers/Api/ChildrenController.php @@ -96,7 +96,13 @@ class ChildrenController extends Controller { public function checkRegisterMain (Request $r) { // トークンの確認 - if (null === ($get = TelActivation::select('tel')->where('token', $r->token)->first())) { + if (null === ($get = TelActivation::select('tel', 'ttl')->where('token', $r->token)->first())) { + return ['status_code' => 400, 'error_messages' => ['不正な登録トークン。']]; + } + + // トークンの有効期限が切れた場合 + if (time() > strtotime($get->ttl)) { + TelActivation::where('token', $r->token)->delete(); return ['status_code' => 400, 'error_messages' => ['不正な登録トークン。']]; } diff --git a/backend/app/Http/Controllers/Api/FathersController.php b/backend/app/Http/Controllers/Api/FathersController.php index a446d388..7d3d037b 100644 --- a/backend/app/Http/Controllers/Api/FathersController.php +++ b/backend/app/Http/Controllers/Api/FathersController.php @@ -142,7 +142,13 @@ class FathersController extends Controller { public function checkRegisterMain (Request $r) { // トークンの確認 - if (null === ($get = EmailActivation::where('token', $r->token)->first())) { + if (null === ($get = EmailActivation::select('ttl')where('token', $r->token)->first())) { + return ['status_code' => 400, 'error_messages' => ['不正な登録トークン。']]; + } + + // トークンの有効期限が切れた場合 + if (time() > strtotime($get->ttl)) { + EmailActivation::where('token', $r->token)->delete(); return ['status_code' => 400, 'error_messages' => ['不正な登録トークン。']]; }