kwcham

Member Since 4 Months Ago

Experience Points
210
Total
Experience

4,790 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
1
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 1
210 XP
Apr
22
2 weeks ago
Apr
20
2 weeks ago
Apr
19
2 weeks ago
Activity icon

Replied to Reset Password Token In Email Link Does Not Match In Database Table

Sorry, maybe I am a bit confuse on encrypt and bcrypt. I meant bcrypt instead of encrypt.

You are right. The email is the one sent out to user when user click confirm when they enter their email address in order to request for reset password link. User will read this email and click the link to go to the reset password page and provide new password.

I am getting “password reset token is invalid” when user side tries to submit the new password.

Is there a way to verify that the token sent by link is the same token hashed in database?

Apr
18
3 weeks ago
Activity icon

Replied to Reset Password Token In Email Link Does Not Match In Database Table

Sorry, let me restructure my questions.

I try to create the reset password feature by following Laravel 8 example. I created 2 views, one for user to enter their email and one for entering their password and confirmed password. The feature works fine until user press the button to submit the new password. The validation shows "This password reset token is invalid".

So I tried to do comparison on the token in the link and encrypted token in database by using code in my first example (Hash::check). The result is they are not the same.

I did an experiment by doing bcrypt('abc') on both of the views, they gave different output. So obviously every time bcrypting the same string will give different results.

I wonder how should I tackle this problem. Or where should I start investigating?

Activity icon

Replied to Reset Password Token In Email Link Does Not Match In Database Table

Sorry, I will do that.

Updated: Already format the code, anyone can help???

Apr
17
3 weeks ago
Activity icon

Replied to Reset Password Token In Email Link Does Not Match In Database Table

@neilstee , yes, I understand that token in db is encrypted and token in link is not. They are not the same after I encrypt the token as what you said.

Actually I tried with bcrypt('abc'); in both of my blade files, they give different encrypted value.

I did the following and it says not same (comparing the db value with link in my controller reset function),

$pass = DB::table('password_resets')->where('email', '[email protected]')->value('token');
if(Hash::check($request['token'], $pass)) {
    dd('same');
 } else {
    dd('not same');
 }
Apr
16
3 weeks ago
Activity icon

Started a new Conversation Reset Password Token In Email Link Does Not Match In Database Table

I got this "This password reset token is invalid." error when creating the password reset feature using Laravel 8. The problem is the token sent by email is not matched with the token stored in database table. I used below code to check the equality of these two values and it give "not the same" result.

$pass = DB::table('password_resets')->where('email', '[email protected]')->value('token');
        if(Hash::check($request['token'], $pass))
        {
            dd('same');
         } else {
             dd('not same');
         }

I hope anyone can pinpoint on what i did wrongly or anything that i missed.

My web.php:

Route::get('/forgot_password', '[email protected]')->name(ResetPasswordConstant::RESET_PASSWORD_ROUTE_REQUEST);
Route::post('/forgot_password', '[email protected]')->name(ResetPasswordConstant::RESET_PASSWORD_ROUTE_EMAIL);
Route::get('/reset_password/{token}', '[email protected]')->name(ResetPasswordConstant::RESET_PASSWORD_ROUTE_RESET);
Route::post('/reset_password', '[email protected]')->name(ResetPasswordConstant::RESET_PASSWORD_ROUTE_UPDATE);

My controller:

public function email(Request $request)
    {
        $request->validate(['email' => 'required|email']);

        $status = Password::sendResetLink($request->only('email'));

        return $status === Password::RESET_LINK_SENT ? back()->with(['status' => __($status)]) : back()->withErrors(['email' => __($status)]);
    }
public function update(Request $request)
    {
        $request->validate([
            'token' => 'required',
            'email' => 'required|email',
            'password' => 'required|min:8|confirmed',
        ]);

        $status = Password::reset(
            $request->only('email', 'password', 'password_confirmation', 'token'),
            function ($user, $password) use ($request) {
                $user->forceFill([
                    'password' => Hash::make($password)
                ])->setRememberToken(Str::random(60));
    
                $user->save();
    
                event(new PasswordReset($user));
            }
        );
    
        return $status == Password::PASSWORD_RESET ? redirect()->route('login')->with('status', __($status)) : back()->withErrors(['email' => [__($status)]]);
    }

password_resets db table:

# email, token, created_at
'[email protected]', 'yLwuR6YvjMvqGykxOycMX.dqu/vF1PIxd05mx2FQIS1YacY6aVhmG', '2021-04-16 14:00:06'

email link sent:

http://localhost:8001/reset_password/5a266d95acd1184bc0d=
9cb74bb3cce1ae28a619037214a41bf4af3ee64843337