public AuthenticationThenMainMenuFlow(
            Func <Task <Tuple <string, UserT> > > fetchCsrfAndUserOrNull,
            Func <string, string, Task <Tuple <string, UserT> > > loginByUserAndPasswdGettingCsrfAndUser,
            Func <Task <Unit> > logoutOper,
            Func <UserT, Func <IFormRenderer <HTMLElement> >, IEnumerable <MenuItemUserModel> > menuItemsProvider,
            Func <MenuItemModel, Tuple <HTMLElement, Action <string> > > customItemBuilder = null,
            Func <string> programNameProvider = null,
            Func <LabelDescr, IActionView <HTMLElement> > customActionBuilder = null)
        {
            _menuItemsProvider = menuItemsProvider;

            _fetchUser = new RemoteActionsCallerForm(new RemoteActionsCallerFormView(), x =>
                                                     x.Add(fetchCsrfAndUserOrNull, y => {
                StoreCsrf(y?.Item1);
                _currentUserOrNull = y != null ? y.Item2 : default(UserT);
            }));

            var loginFormView = new LoginFormView(customActionBuilder);

            _loginForm = new LoginForm <UserT>(loginFormView, loginByUserAndPasswdGettingCsrfAndUser, (csrfToken, curUser) => {
                StoreCsrf(csrfToken);
                _currentUserOrNull = curUser;
            });
            if (programNameProvider != null)
            {
                _loginForm.TitleProvider = () => programNameProvider();
            }

            _mainMenuFormView = new HorizontalLinksMenuFormView(customItemBuilder);
            _mainMenuForm     = new MenuForm(_mainMenuFormView, new List <MenuItemUserModel>());
            _authProblemMsg   = new InformationalMessageForm("", I18n.Translate("Authentication problem"));
            _runLogout        = new RemoteActionsCallerForm(x => x.Add(logoutOper));
            _logoutConfirm    = new ConfirmMessageForm(
                I18n.Translate("Are you sure you want to log out?"), I18n.Translate("Logging out"));
        }
Ejemplo n.º 2
0
 public ShowMessageFlow(string message, string title, TextType textType = TextType.TreatAsText)
 {
     _msg = new InformationalMessageForm(message, title, textType);
 }