Fires the windows authentication event.

@param User       $user
@param mixed|null $model

@return void
486187
protected function fireAuthenticatedEvent(User $user, $model = null)
    {
        Event::dispatch(new AuthenticatedWithWindows($user, $model));
    }
1236807
protected function checkPermission(User $user, $model, $action)
    {
        $dataType = Admin::model('DataType');
        $dataType = $dataType->where('model_name', get_class($model))->first();

        return $user->hasPermission($action.'_'.$dataType->slug);
    }
637496
public function deactivateUser(User $user)
    {
        /** @var Account $account */
        foreach ($user->getAccounts() as $account) {
            $account->setExpirationDate($this->now);
            $this->accountRepository->update($account);
        }
        $this->emitUserDeactivated($user);
    }
959250
public function newAction(User $user = null)
    {
        $this->view->assignMultiple([
            'currentUser' => $this->currentUser,
            'user' => $user,
            'roles' => $this->policyService->getRoles(),
            'providers' => $this->getAuthenticationProviders()
        ]);
    }
1010008
public function delete(User $user): void
    {
        // Don't delete the logs, just set the user to null.
        DB::table('log')
            ->where('user_id', '=', $user->id())
            ->update(['user_id' => null]);

        // Take over the user’s pending changes. (What else could we do with them?)
        DB::table('change')
            ->where('user_id', '=', $user->id())
            ->where('status', '=', 'rejected')
            ->delete();

        DB::table('change')
            ->where('user_id', '=', $user->id())
            ->update(['user_id' => Auth::id()]);

        // Delete settings and preferences
        DB::table('block_setting')
            ->join('block', 'block_setting.block_id', '=', 'block.block_id')
            ->where('user_id', '=', $user->id())
            ->delete();

        DB::table('block')->where('user_id', '=', $user->id())->delete();
        DB::table('user_gedcom_setting')->where('user_id', '=', $user->id())->delete();
        DB::table('user_setting')->where('user_id', '=', $user->id())->delete();
        DB::table('message')->where('user_id', '=', $user->id())->delete();
        DB::table('user')->where('user_id', '=', $user->id())->delete();
    }
353156
protected function firePassedEvent($username, $password)
    {
        if (isset($this->events)) {
            $this->events->fire(new Passed($this->connection, $username, $password));
        }
    }
680412
public function logout(Event $event, array $user)
    {
        $controller = $this->_registry->getController();
        if (empty($controller->Cookie)) {
            $controller->loadComponent('Cookie');
        }
        $controller->Cookie->delete('User.Cookie');
    }
697969
protected function fireCompletedEvent(Authenticatable $user)
    {
        if ($this->completedEvent === null || !class_exists($this->completedEvent)) {
            return;
        }

        event(new $this->completedEvent($user));
    }
620427
public function onPreCreate(UserEvent $event)
    {
        /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
        $user = $event->getResource();

        // Generates a secured password.
        if (0 === strlen($user->getPlainPassword())) {
            $this->userManager->generatePassword($user);
            $user->setEnabled(true);

            // Warn about the generated password
            $password = $user->getPlainPassword();
            $event
                ->addMessage(new ResourceMessage(
                    sprintf('Generated password : "%s".', $password),
                    ResourceMessage::TYPE_INFO
                ))
                ->addData('password', $password)
            ;
        }

        $this->userManager->updatePassword($user);
        $this->userManager->updateCanonicalFields($user);
    }
271542
protected function fireLoginEvent($user, $remember = false)
    {
        if (isset($this->events)) {
            $this->events->fire('auth.login', [$user, $remember]);
        }
    }
976510
protected function fireAuthenticatedEvent($user)
    {
        if (isset($this->events)) {
            $this->events->dispatch(new Events\Authenticated(
                $this->name, $user
            ));
        }
    }
366854
protected function fireOtherDeviceLogoutEvent($user)
    {
        if (isset($this->events)) {
            $this->events->dispatch(new Events\OtherDeviceLogout(
                $this->name, $user
            ));
        }
    }
196368
public function requestNewPassword(User $user)
    {
        $user->setPasswordRequestedAt(new \DateTime());
        $user->resetAuthenticationToken();
        $user->setEmailSent(false);
        $this->save($user);
    }
787807
public static function login(UserInterface $user): void
    {
        Session::regenerate(false);
        Session::put('wt_user', $user->id());
    }
1314241
public function handleEvent(Event $event, UserNotificationEventHandler $service)
    {
        // If our event is the wrong type, just do a null/void return
        if (!$event instanceof DeactivateUser) {
            return;
        }

        $entity = $event->getUserEntity();

        if ($entity) {
            $service->deactivated($event);
        }
    }
1131037
public function onPreUpdate(UserEvent $event)
    {
        /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
        $user = $event->getResource();

        $this->userManager->updatePassword($user);
        $this->userManager->updateCanonicalFields($user);
    }
758746
protected function restore(User $user, Model $model)
    {
        if (
            $this->isUsingSoftDeletes($model) &&
            $model->trashed() &&
            $user->isEnabled()
        ) {
            // If the model has soft-deletes enabled, the model is
            // currently deleted, and the LDAP user account
            // is enabled, we'll restore the users model.
            $model->restore();

            if ($this->isLogging()) {
                $type = get_class($user->getSchema());

                logger()->info("Restored user {$user->getCommonName()}. Their {$type} user account has been re-enabled.");
            }
        }
    }