Permalink
Browse files

Improve reset password logic

  • Loading branch information...
summerblue committed Feb 7, 2017
1 parent 4d67f0b commit 9e20792a11eee33db77f38cc6d5b822d0a1811f1
Showing with 7 additions and 11 deletions.
  1. +6 −5 app/Http/Controllers/UsersController.php
  2. +0 −5 app/Models/User.php
  3. +1 −1 database/seeds/UsersTableSeeder.php
@@ -56,7 +56,7 @@ public function store(Request $request)
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => $request->password,
'password' => bcrypt($request->password),
]);
$this->sendEmailConfirmationTo($user);
@@ -81,10 +81,11 @@ public function update($id, Request $request)
$user = User::findOrFail($id);
$this->authorize('update', $user);
$data = array_filter([
'name' => $request->name,
'password' => $request->password,
]);
$data = [];
$data['name'] = $request->name;
if ($request->password) {
$data['password'] = bcrypt($request->password);
}
$user->update($data);
session()->flash('success', '个人资料更新成功!');
@@ -54,11 +54,6 @@ public function gravatar($size = '100')
return "http://www.gravatar.com/avatar/$hash?s=$size";
}
public function setPasswordAttribute($password)
{
$this->attributes['password'] = bcrypt($password);
}
public function statuses()
{
return $this->hasMany(Status::class);
@@ -18,7 +18,7 @@ public function run()
$user = User::find(1);
$user->name = 'Aufree';
$user->email = 'aufree@estgroupe.com';
$user->password = 'password';
$user->password = bcrypt('password');
$user->is_admin = true;
$user->activated = true;
$user->save();

0 comments on commit 9e20792

Please sign in to comment.