Skip to content

Commit

Permalink
Administrator password hashing method moved from command to model
Browse files Browse the repository at this point in the history
  • Loading branch information
sleeping-owl committed May 12, 2015
1 parent be1fca6 commit e5a292e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/SleepingOwl/Admin/Commands/AdministratorsCommand.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php namespace SleepingOwl\Admin\Commands;

use Config;
use Hash;
use Illuminate\Console\Command;
use Illuminate\Support\Str;
use SleepingOwl\Admin\Commands\Compilers\ModelCompiler;
Expand Down Expand Up @@ -98,7 +97,7 @@ protected function createNewAdministrator()
{
Administrator::create([
'username' => $username,
'password' => Hash::make($password),
'password' => $password,
'name' => $name,
]);
} catch (\Exception $e)
Expand Down Expand Up @@ -156,7 +155,7 @@ protected function changePassword()
return;
}

Administrator::find($id)->fill(['password' => Hash::make($password)])->save();
Administrator::find($id)->fill(['password' => $password])->save();

$this->info('Password was changed.');
}
Expand Down
9 changes: 9 additions & 0 deletions src/SleepingOwl/AdminAuth/Entities/Administrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Hash;

class Administrator extends \Eloquent implements AuthenticatableContract
{
Expand All @@ -18,4 +19,12 @@ class Administrator extends \Eloquent implements AuthenticatableContract
'remember_token',
];

public function setPasswordAttribute($value)
{
if ( ! empty($value))
{
$this->attributes['password'] = Hash::make($value);
}
}

}

0 comments on commit e5a292e

Please sign in to comment.