/** * {@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; }
/** * 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 User|bool * @throws \InvalidArgumentException */ public function register(array $credentials, $callback = null) { return $this->sentinel->register($credentials, $callback); }
/** * 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 * @static */ public static function register($credentials, $callback = null) { return \Cartalyst\Sentinel\Sentinel::register($credentials, $callback); }