Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.7] Database-less Password Reset #23706

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
<div class="card-header">{{ __('Reset Password') }}</div>

<div class="card-body">
<form method="POST" action="{{ route('password.request') }}">
<form method="POST" action="{{ URL::full() }}">
@csrf

<input type="hidden" name="token" value="{{ $token }}">

<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>

<div class="col-md-6">
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ $email or old('email') }}" required autofocus>
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ $email ?? old('email') }}" required autofocus>

@if ($errors->has('email'))
<span class="invalid-feedback">
Expand Down
24 changes: 14 additions & 10 deletions src/Illuminate/Auth/Notifications/ResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,36 @@

namespace Illuminate\Auth\Notifications;

use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\URL;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;

class ResetPassword extends Notification
{
/**
* The password reset token.
* The callback that should be used to build the mail message.
*
* @var string
* @var \Closure|null
*/
public $token;
public static $toMailCallback;

/**
* The callback that should be used to build the mail message.
* The number minutes for which the reset link should be considered valid.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Number OF minutes

*
* @var \Closure|null
* @var int
*/
public static $toMailCallback;
protected $expiration;

/**
* Create a notification instance.
*
* @param string $token
* @param int $expiration
* @return void
*/
public function __construct($token)
public function __construct($expiration = 60)
{
$this->token = $token;
$this->expiration = $expiration;
}

/**
Expand Down Expand Up @@ -57,7 +59,9 @@ public function toMail($notifiable)

return (new MailMessage)
->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
->action('Reset Password', URL::signedRoute('password.reset', [
'email' => $notifiable->getEmailForPasswordReset(),
], Carbon::now()->addMinutes($this->expiration)))
->line('If you did not request a password reset, no further action is required.');
}

Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Auth/Passwords/CanResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public function getEmailForPasswordReset()
/**
* Send the password reset notification.
*
* @param string $token
* @param int $expiration
* @return void
*/
public function sendPasswordResetNotification($token)
public function sendPasswordResetNotification($expiration = 60)
{
$this->notify(new ResetPasswordNotification($token));
$this->notify(new ResetPasswordNotification($expiration));
}
}
204 changes: 0 additions & 204 deletions src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php

This file was deleted.

Loading