def login_user(self,
                   user: User,
                   remember: Optional[bool] = None,
                   duration: Optional[timedelta] = None,
                   force: bool = False,
                   fresh: bool = True,
                   ) -> bool:
        if not force:
            if not user.active:
                raise AuthenticationError(
                    _('flask_unchained.bundles.security:error.disabled_account'))
            if (not user.confirmed_at
                    and self.security.confirmable
                    and not self.security.login_without_confirmation):
                raise AuthenticationError(
                    _('flask_unchained.bundles.security:error.confirmation_required'))
            if not user.password:
                raise AuthenticationError(
                    _('flask_unchained.bundles.security:error.password_not_set'))
        session['user_id'] = getattr(user, user.Meta.pk)
        session['_fresh'] = fresh
        session['_id'] = app.login_manager._session_identifier_generator()
        if remember is None:
            remember = app.config.SECURITY_DEFAULT_REMEMBER_ME
        if remember:
            session['remember'] = 'set'
            if duration is not None:
                try:
                    session['remember_seconds'] = duration.total_seconds()
                except AttributeError:
                    raise Exception('duration must be a datetime.timedelta, '
                                    'instead got: {0}'.format(duration))
        _request_ctx_stack.top.user = user
        user_logged_in.send(app._get_current_object(), user=user)
        identity_changed.send(app._get_current_object(),
                              identity=Identity(user.id))
        return True