Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

laravel - Hash::make not working route.php file

I'm having auth problems in my new laravel 4 app. The one odd thing I have noticed and this might be why is that when I do:

var_dump(Hash::check('secret', Hash::make('secret')));

in the DB seeder (where I create my hashed passwords) I get true.

When I run that same command directly in a route, I get false.

Also, when I do a simple:

var_dump(Hash::make('secret'));

directly in the route it is still false.

Is this broken or am I missing something ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is something wrong with your install. This is what I get:

Route::get('/', function()
{
    var_dump(Hash::make('secret'));  // Gives a bcrypt string output
    var_dump(Hash::check('secret', Hash::make('secret'))); // Output true
}

Did you do a composer update, and forget to update the app itself? That is the most common cause of Laravel 4 issues at the moment.

This forum post gives a detailed answer on how to update the main L4 app after a composer update.

Edit: I will post the forum stuff here - because you need to be logged in to Laravel forums to see beta section:

If you run composer update and experience problems after doing so, you most likely need to merge in changes from the application skeleton, which is the develop branch of laravel/laravel.

If you originally cloned this repository and still share a git history with it, you can usually merge in changes easily. Assuming your remote is 'upstream' pointed at this repository, you can do the following:

git fetch upstream
git merge upstream/develop 

Alternatively you could cherry pick in individual commits from the develop branch, but I won't cover that here.

If you downloaded the zip distribution originally or removed the upstream history, you can still resolve your problem manually. Look at the commits on this branch and make any changes not present in your application. Usually the breaking changes are simple configuration changes.

Once Laravel 4 stable has been released the need to do this will be much less frequent, but these changes can still occur. Keep in mind that during this beta application breaking changes are very likely to happen.

Thanks to Kindari for the forum post.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...