Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function register(Request $request)
- {
- $temp_password = str_random(20);
- $request->request->add(['password' => $temp_password]);
- $this->validator($request->all())->validate();
- event(new Registered($user = $this->create($request->all())));
- $key = env('APP_KEY');
- if (Str::startsWith($key, 'base64:')) {
- $key = base64_decode(substr($key, 7));
- }
- $reset_token = hash_hmac('sha256', Str::random(40), $key);
- DB::table('password_resets')->insert([
- 'email' => $request->email,
- 'token' => Hash::make($reset_token),
- 'created_at' => Carbon::now(),
- ]);
- return $this->registered($request, $user)
- ?: redirect($this->redirectPath());
- }
- protected function registered(Request $request, $user) {
- $user->notify(new UserRegisteredNotification($user));
- }
- In UserRegisteredNotification:
- public function toMail($notifiable) {
- $pw_reset = DB::table('password_resets')->where('email', $this->user->email)->first();
- return (new MailMessage)
- ...
- ->action('Reset Password', url(config('app.url').route('password.reset', $pw_reset->token, false)))
- ...
- }
- In the password reset e-mail, it has the hashed token and so the link doesn't work.
- How do I get the pre-hashed token to the Notification class?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement