سؤال

أحاول تنفيذ منطق إعادة تعيين كلمة المرور.يحصل المستخدم على الرابط لإعادة تعيين كلمة المرور في البريد الإلكتروني.يبدو عنوان 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