/**
* Registers a user. You may provide a callback to occur before the user
* is saved, or provide a true boolean as a shortcut to activation.
*
* @param array $credentials
* @param \Closure|bool $callback
* @return \Cartalyst\Sentinel\Users\UserInteface|bool
* @throws \InvalidArgumentException
*/
public function register(array $credentials, $callback = null)
{
if ($callback !== null && !$callback instanceof Closure && !is_bool($callback)) {
throw new InvalidArgumentException('You must provide a closure or a boolean.');
}
$this->fireEvent('sentinel.registering', $credentials);
$valid = $this->users->validForCreation($credentials);
if ($valid === false) {
return false;
}
$argument = $callback instanceof Closure ? $callback : null;
$user = $this->users->create($credentials, $argument);
if ($callback === true) {
$this->activate($user);
}
$this->fireEvent('sentinel.registered', $user);
return $user;
}