Esempio n. 1
0
        private void ShowLoginInternal(bool canChangeUrl, Action onSuccess = null)
        {
            var config = _appConfigStorage.Load();

            AuthProcess.Start(
                getAuthenticationData: async() =>
            {
                var view = (Application.Current.MainWindow as MetroWindow);

                LoginWithUrlDialogSettings settings = new LoginWithUrlDialogSettings
                {
                    AnimateShow              = true,
                    AnimateHide              = true,
                    AffirmativeButtonText    = "Login",
                    NegativeButtonText       = "Exit",
                    NegativeButtonVisibility = Visibility.Visible,
                    UrlWatermark             = "Url",
                    ShouldHideUrl            = !canChangeUrl,
                    InitialUrl                 = config.HostUrl,
                    EmailWatermark             = "*****@*****.**",
                    PhoneWatermark             = "79998887766",
                    PasswordWatermark          = "Password",
                    EnablePasswordPreview      = true,
                    RememberCheckBoxVisibility = Visibility.Visible,
                    RememberCheckBoxChecked    = config.ShouldRemember,
                };

                var loginDialog = new LoginWithUrlDialog(view, settings)
                {
                    Title = "Login"
                };
                await view.ShowMetroDialogAsync(loginDialog);
                var result = await loginDialog.WaitForButtonPressAsync();
                await view.HideMetroDialogAsync(loginDialog);
                return(result);
            },
                authentication: async(x) =>
            {
                if (x == null)
                {
                    return(false);
                }

                try
                {
                    config.HostUrl        = x.Url;
                    config.ShouldRemember = x.ShouldRemember;
                    _appConfigStorage.Save(config);

                    _domain0Context.HostUrl        = x.Url;
                    _domain0Context.ShouldRemember = x.ShouldRemember;

                    var loginTask = GetLoginTask(x);

                    var userProfile = await _shell.ShowProgress("Login", "Trying to login...")
                                      .WaitOnly(loginTask);

                    var login = x.LoginMode == LoginMode.Email
                            ? userProfile.Email
                            : userProfile.Phone;
                    _shell.Container.Resolve <IDockWindow>().Title =
                        $"Domain0.Desktop - {userProfile.Name} - {login}";

                    return(true);
                }
                catch (AuthenticationContextException e)
                {
                    await _shell.HandleException(e.InnerException, "Login failed", false);
                    return(false);
                }
            },
                authenticationSuccess: () => onSuccess?.Invoke(),
                authenticationFail: () => Application.Current.MainWindow?.Close()
                );
        }
Esempio n. 2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var shell = UiStarter.Start <IDockWindow>(
                new Bootstrap(),
                new UiShowStartWindowOptions
            {
                Title         = "Kanban.Desktop",
                ToolPaneWidth = 100
            });

            AuthProcess.Start(
                getAuthenticationData: () => LoginDialog.GetAutenticationDataTask(),
                authentication: async(x) =>
            {
                if (x == null)
                {
                    return(false);
                }

                var authContext = shell.Container.Resolve <IAuthenticationContext>();
                return(await authContext.LoginAsync(x.Username, x.Password));
            },
                authenticationSuccess: () =>
            {
                shell.ShowView <ISettingsView>(
                    options: new UiShowOptions
                {
                    Title = "Settings"
                });
                shell.ShowView <IKanbanBoardView>();
                shell.ShowView <IKanbanBoardView>(
                    new KanbanViewRequest
                {
                    ConfigurtaionName = "h_status_v_assigned_c_subject_treker_details"
                },
                    new KanbanShowOptions
                {
                    Title = "Kanban dynamic dimension",
                });
                shell.ShowView <IKanbanBoardView>(
                    new KanbanViewRequest
                {
                    ConfigurtaionName = "ods"
                },
                    new KanbanShowOptions
                {
                    Title = "ods",
                });

                shell.ShowView <IIssueView>(
                    new IssueViewRequest
                {
                    IssueId = 4689
                });

                shell.ShowTool <IIssuesTool>();
            },
                authenticationFail: () => Current.MainWindow.Close());
        }