Skip to content

Commit

Permalink
Use RedirectIfAuthorized middleware on password reset & activate pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell committed Nov 23, 2023
1 parent fbd53fb commit fb80ec2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Http/Controllers/ActivateAccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

use Illuminate\Support\Facades\Password;
use Statamic\Auth\Passwords\PasswordReset;
use Statamic\Http\Middleware\CP\RedirectIfAuthorized;

class ActivateAccountController extends ResetPasswordController
{
public function __construct()
{
$this->middleware(RedirectIfAuthorized::class);
}

protected function resetFormAction()
{
return route('statamic.account.activate.action');
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Middleware/CP/RedirectIfAuthorized.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class RedirectIfAuthorized
*/
public function handle($request, Closure $next, $guard = null)
{
if (User::current()) {
return redirect(cp_route('index'));
if ($user = User::current()) {
return redirect($user->can('access cp') ? cp_route('index') : '/');
}

return $next($request);
Expand Down

0 comments on commit fb80ec2

Please sign in to comment.