Prevent double activation potential with createWithRoles* methods

Signed-off-by: 's avatarMicheal Mand <micheal@kmdwebdesigns.com>
parent 57e2caaa
...@@ -68,15 +68,11 @@ class SentinelUserRepository implements UserRepository ...@@ -68,15 +68,11 @@ class SentinelUserRepository implements UserRepository
public function createWithRoles($data, $roles, $activated = false) public function createWithRoles($data, $roles, $activated = false)
{ {
$this->hashPassword($data); $this->hashPassword($data);
$user = $this->create((array) $data); $user = $this->create((array) $data, $activated);
if (!empty($roles)) { if (!empty($roles)) {
$user->roles()->attach($roles); $user->roles()->attach($roles);
} }
if ($activated) {
$this->activateUser($user);
}
} }
/** /**
...@@ -90,16 +86,12 @@ class SentinelUserRepository implements UserRepository ...@@ -90,16 +86,12 @@ class SentinelUserRepository implements UserRepository
public function createWithRolesFromCli($data, $roles, $activated = false) public function createWithRolesFromCli($data, $roles, $activated = false)
{ {
$this->hashPassword($data); $this->hashPassword($data);
$user = $this->user->create((array) $data); $user = $this->user->create((array) $data, $activated);
if (!empty($roles)) { if (!empty($roles)) {
$user->roles()->attach($roles); $user->roles()->attach($roles);
} }
if ($activated) {
$this->activateUser($user);
}
return $user; return $user;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment