middleware('guest'); } /** * Show the application registration form. * * @return \Illuminate\View\View */ public function showRegistrationForm() { // 개인정보처리방침 $privacy = (new Document)->findByCode('privacy'); // 비밀번호 조건 확인 $passwordMinLength = config('password_min_length'); $passwordUppercaseLength = config('password_uppercase_length'); $passwordNumbersLength = config('password_numbers_length'); $passwordSpecialcharsLength = config('password_specialchars_length'); $passwordGuideTip = ""; if($passwordMinLength > 0) { $passwordGuideTip .= sprintf('최소 %d자 이상, ', $passwordMinLength); } if($passwordUppercaseLength > 0) { $passwordGuideTip .= sprintf('대문자 %d자 이상, ', $passwordUppercaseLength); } if($passwordNumbersLength > 0) { $passwordGuideTip .= sprintf('숫자 %d자 이상, ', $passwordNumbersLength); } if($passwordSpecialcharsLength > 0) { $passwordGuideTip .= sprintf('특수문자 %d자 이상, ', $passwordSpecialcharsLength); } $passwordGuideTip = rtrim($passwordGuideTip, ', '); return view('auth.register', [ 'privacy' => $privacy, 'passwordGuideTip' => $passwordGuideTip ]); } /** * Get a validator for an incoming registration request. * * @param array $data * @return \Illuminate\Contracts\Validation\Validator */ protected function validator(array $data) { return Validator::make($data, [ 'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email', new DeniedEmail], 'nickname' => ['required', 'string', 'unique:users,nickname', 'min:2', 'max:20', new AllowNickname], 'password' => ['required', 'string', 'min:' . config('password_min_length', 4), 'confirmed', new NumberLength, new SpecialCharLength, new UppercaseLength], 'agree_1' => 'required|numeric|in:1', 'agree_2' => 'required|numeric|in:2' ], [], [ 'email' => '이메일', 'nickname' => '닉네임', 'password' => '비밀번호', 'agree_1' => '이용약관 동의', 'agree_2' => '개인정보처리방침 동의' ]); } /** * Create a new user instance after a valid registration. * * @param array $data * @return \App\Models\User */ protected function create(array $data): mixed { return (new User)->register($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) { // 회원가입 차단 확인 if(config('use_register_block')) { return back()->withErrors('현재 회원 신청이 차단되어 회원가입을 할 수 없습니다. 관리자에게 문의하십시오.'); } $this->validator($request->all())->validate(); event(new Registered($user = $this->create($request->all()))); $this->guard()->login($user); if ($response = $this->registered($request, $user)) { return $response; } return $request->wantsJson() ? new JsonResponse([], 201) : redirect($this->redirectPath()); } }