문제

비밀번호 재설정 로직을 구현하려고 합니다.사용자는 이메일에서 비밀번호를 재설정할 수 있는 링크를 받습니다.URL은 다음과 같습니다

http://example.com/reset/resetcode

나는 그것에 대해 정의된 경로를 가지고 있습니다:

Route::get('reset/{resetcode}', function(){
    return View::make('users.reset_password');
});

양식을 제출하기 위해 뷰에 렌더링됩니다. email, new password 등.양식 게시물의 경우 경로는 다음과 같이 정의되었습니다.

Route::post('reset/{resetcode}', array( 'as' => 'reset', 'uses' => 'UserController@passwordReset'));

나는 그것을 잡는다 resetcode ~에서 post route 안에 passwordReset 아래 컨트롤러

public function passwordReset($resetcode)
{ 
    $validation = Validator::make(Input::all(), UserModel::$rulesPasswordReset);
    if ($validation->passes())
    { 
    try
    {
    // Find the user using the user email address
    $user = Sentry::findUserByLogin(Input::get('email'));

    // Check if the reset password code is valid
    if ($user->checkResetPasswordCode($resetcode))
    {
        // Attempt to reset the user password
        if ($user->attemptResetPassword($resetcode, 'new_password'))
        {
        // Password reset passed
         }
         else
         {
        // Password reset failed
         }
    }
    else
    {
        // The provided password reset code is Invalid
    }
        }
        catch (Cartalyst\Sentry\Users\UserNotFoundException $e)
        {
       echo 'User was not found.';
        }
    }
    else return Redirect::route('reset')->withInput()
    ->withErrors($validation)
    ->with('title', 'resetrequestfailure')
    ->with('message', 'Seems like you made some errors.');
   }

내가 겪고 있는 문제는 내가 할 때이다. Redirect::route 검증이 실패한 후. 나는 받고있다 resetcode 다음에 대해 정의된 경로에서 post.유효성 검사에 실패하면 리디렉션 경로가 엉망이 되어 resetcode 두 번째.예상되는 형식의 URL

 http://example.com/reset/8f1Z7wA4uVt7VemBpGSfaoI9mcjdEwtK8elCnQOb

된다

http://bcnet.org/reset/%7Bcode%7D

그것은 다음과 관련이 있습니다 /{resetcode} 경로의 일부이며 이는 가변적이므로 어떻게 올바른 것을 얻을 수 있습니까? resetcode 유효성 검사가 실패한 후에도 URL은 그대로 유지됩니다.아니면 어떻게 적절하게 고칠 수 있습니까? Redirect::route 유효성 검사 실패 후.

도움이 되었습니까?

해결책

다음을 포함해야 합니다. $resetcode 돌아오는 길에

else return Redirect::route('reset', $resetcode)->withInput()
    ->withErrors($validation)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top