/**
  * Create user registration.
  *
  * @param Request $request
  * @param AppMailer $mailer
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $this->validate($request, $this->validateRegistrationForm());
     $user = $this->users->create($request->all());
     if (Auth::attempt($this->getCredentials($request))) {
         $mailer->sendEmailVerificationTo($user);
     }
     return redirect('/');
 }
 /**
  * Update the user profile.
  *
  * @param Request $request
  * @param AppMailer $mailer
  * @return \Illuminate\Http\RedirectResponse
  */
 public function updateProfile(Request $request, AppMailer $mailer)
 {
     $userData = $request->all();
     $this->validate($request, ['name' => 'required|max:255', 'nickname' => $userData['nickname'] != $this->user->nickname ? 'max:255|unique:users' : '', 'email' => $userData['email'] != $this->user->email ? 'required|email|max:255|unique:users' : '']);
     if ($userData['email'] != $this->user->email) {
         $this->user->email = $userData['email'];
         $this->user->token = str_random(30);
         $this->user->is_verified = false;
     }
     $this->user->name = $userData['name'];
     $this->user->nickname = $userData['nickname'];
     $this->user->save();
     if (!$this->user->is_verified) {
         $mailer->sendEmailVerificationTo($this->user);
         flash()->overlay("Profile updated", "Email verification link has been sent to your email address.\\nPlease check your inbox and click on the link.", "success");
     } else {
         flash()->success("Success", "Your profile was successfully updated.");
     }
     return redirect()->back();
 }
Example #3
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request, AppMailer $mailer)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $user = $this->create($request->all());
     $mailer->sendEmailVerificationTo($user);
     \Notification::success(trans('registration.please_verify_email'));
     return redirect('/');
 }