Skip to content

Commit

Permalink
fix: 提交註冊後不直接登入帳號,這會害死我的
Browse files Browse the repository at this point in the history
  • Loading branch information
Kantai235 committed Aug 17, 2024
1 parent 05dac54 commit 1c44410
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use App\Http\Controllers\Controller;
use App\Rules\Captcha;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules;
Expand Down Expand Up @@ -137,4 +140,25 @@ protected function create(array $data)

return $this->userService->registerUser($data);
}

/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
public function register(Request $request)
{
$this->validator($request->all())->validate();

event(new Registered($user = $this->create($request->all())));

if ($response = $this->registered($request, $user)) {
return $response;
}

return $request->wantsJson()
? new JsonResponse([], 201)
: redirect($this->redirectPath());
}
}

0 comments on commit 1c44410

Please sign in to comment.