/**
* {@inheritDoc}
*/
public function register(array $data, $validate = true)
{
$this->rules = ['email' => 'required|unique:users', 'password' => 'required|confirmed', 'password_confirmation' => 'required'];
if ($validate) {
$this->validate($data);
}
if (!config('laraflock.dashboard.activations')) {
$this->registerAndActivate($data, false);
return true;
}
try {
$user = $this->sentinel->register($data);
} catch (QueryException $e) {
throw new AuthenticationException(trans('dashboard::dashboard.errors.auth.create'));
}
if (!$user instanceof EloquentUser) {
throw new AuthenticationException(trans('dashboard::dashboard.errors.auth.create'));
}
if (!isset($data['role'])) {
$data['role'] = config('laraflock.dashboard.defaultRole');
}
if (!($role = $this->sentinel->findRoleBySlug($data['role']))) {
throw new RolesException(trans('dashboard::dashboard.errors.role.found'));
}
$role->users()->attach($user);
if (!($activation = $this->illuminateActivationRepository->create($user))) {
throw new AuthenticationException(trans('dashboard::dashboard.errors.auth.activation.create'));
}
return $activation;
}