php - How to regenerate APP_KEY and set new passwords in Laravel 5 -
today restore macbook os yosemite , forgot backup .env
file, lost app_key
.
now paswords not work anymore , understand that. that:
php artisan key:generate
then update passwords using code:
route::get('/', function () { $users = new project\db\user; $users->update(['password' => hash::make('newpasswordhere')]); });
but when try update user using system , change password, can't login. that's code of update($id)
method:
$user = user::getbyid($id); $user->role_id = $request->get('role_id'); $user->first_name = $request->get('first_name'); $user->last_name = $request->get('last_name'); $user->email = $request->get('email'); if ($request->has('password')) { $user->password = hash::make($request->get('password')); } $user->active = $request->get('active'); $user->update();
what doing wrong?
my setup
- macbook pro - yosemite
- php-fpm -
php 5.6.11 (cli) (built: jul 19 2015 15:15:07)
- nginx -
nginx version: nginx/1.8.0
if need more information, tell me please.
i not believe problem, must tell them real cause , solution:
at beginning of project set mutator password attribute.
this mutator in turn encrypting password (yes ... know, not believe did not see it).
public function setpasswordattribute($value) { $this->attributes['password'] = bcrypt($value); }
finally, solution of problem not encrypt password on controller:
if ($request->has('password')) { $user->password = $request->get('password'); }
sorry , thank time!
Comments
Post a Comment