Skip to content

Commit

Permalink
[5.4] Use route() helper instead of url() in Auth (#17718)
Browse files Browse the repository at this point in the history
* Add route name to password reset request form submit.

* Use route names in Auth instead of url function.
  • Loading branch information
kslimani authored and taylorotwell committed Feb 1, 2017
1 parent 3e226e3 commit 44fe5e0
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/Console/stubs/make/views/auth/login.stub
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="panel panel-default">
<div class="panel-heading">Login</div>
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}">
<form class="form-horizontal" role="form" method="POST" action="{{ route('login') }}">
{{ csrf_field() }}

<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
Expand Down Expand Up @@ -54,7 +54,7 @@
Login
</button>

<a class="btn btn-link" href="{{ url('/password/reset') }}">
<a class="btn btn-link" href="{{ route('password.request') }}">
Forgot Your Password?
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
@endif

<form class="form-horizontal" role="form" method="POST" action="{{ url('/password/email') }}">
<form class="form-horizontal" role="form" method="POST" action="{{ route('password.email') }}">
{{ csrf_field() }}

<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
@endif

<form class="form-horizontal" role="form" method="POST" action="{{ url('/password/reset') }}">
<form class="form-horizontal" role="form" method="POST" action="{{ route('password.request') }}">
{{ csrf_field() }}

<input type="hidden" name="token" value="{{ $token }}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="panel panel-default">
<div class="panel-heading">Register</div>
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}">
<form class="form-horizontal" role="form" method="POST" action="{{ route('register') }}">
{{ csrf_field() }}

<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
@if (Auth::guest())
<li><a href="{{ url('/login') }}">Login</a></li>
<li><a href="{{ url('/register') }}">Register</a></li>
<li><a href="{{ route('login') }}">Login</a></li>
<li><a href="{{ route('register') }}">Register</a></li>
@else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Expand All @@ -60,13 +60,13 @@

<ul class="dropdown-menu" role="menu">
<li>
<a href="{{ url('/logout') }}"
<a href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
Logout
</a>

<form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</li>
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/Notifications/ResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ 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('password/reset', $this->token))
->action('Reset Password', route('password.reset', $this->token))

This comment has been minimized.

Copy link
@bbashy

bbashy Mar 20, 2017

Contributor

This is a breaking change if you've overridden the auth routes and named the current password.request as password.reset.

I had people getting /password/reset?9a76b96a9696a96b9696b9a6696ab674ab links in password reset emails.

cc @taylorotwell

->line('If you did not request a password reset, no further action is required.');
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ public function auth()

// Password Reset Routes...
$this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
$this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
$this->post('password/reset', 'Auth\ResetPasswordController@reset');
}
Expand Down

0 comments on commit 44fe5e0

Please sign in to comment.