Esempio n. 1
0
        private async Task <LoginWithUrlDialogData> LoginToRedmine()
        {
            var settings = new LoginWithUrlDialogSettings
            {
                InitialHost                = appConfig.LastRedmineUrl,
                InitialUsername            = appConfig.LastRedmineUser,
                AnimateShow                = true,
                AnimateHide                = true,
                AffirmativeButtonText      = "Login",
                NegativeButtonText         = "Cancel",
                NegativeButtonVisibility   = Visibility.Visible,
                EnablePasswordPreview      = true,
                RememberCheckBoxVisibility = Visibility.Collapsed
            };

            var loginDialog = new LoginWithUrlDialog(null, settings)
            {
                Title = "Login to Redmine"
            };
            await dialCoord.ShowMetroDialogAsync(this, loginDialog);

            var result = await loginDialog.WaitForButtonPressAsync();

            await dialCoord.HideMetroDialogAsync(this, loginDialog);

            if (result != null)
            {
                appConfig.LastRedmineUrl  = result.Host;
                appConfig.LastRedmineUser = result.Username;
            }

            return(result);
        }
Esempio n. 2
0
        private async Task <LoginWithUrlDialogData> LoginToRedmine()
        {
            var settings = new LoginWithUrlDialogSettings
            {
                AnimateShow                = true,
                AnimateHide                = true,
                AffirmativeButtonText      = "Login",
                NegativeButtonText         = "Cancel",
                NegativeButtonVisibility   = Visibility.Visible,
                EnablePasswordPreview      = true,
                RememberCheckBoxVisibility = Visibility.Collapsed
            };

            var loginDialog = new LoginWithUrlDialog(null, settings)
            {
                Title = "Login to Redmine"
            };
            await _dialogCoordinator.ShowMetroDialogAsync(this, loginDialog);

            var result = await loginDialog.WaitForButtonPressAsync();

            await _dialogCoordinator.HideMetroDialogAsync(this, loginDialog);

            return(result);
        }
Esempio n. 3
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()
                );
        }