예제 #1
0
        public static ProjectScanStatuses EditRemark(long resultId, long pathId, string remark)
        {
            LoginData     loginData     = LoginHelper.LoadSaved();
            OidcLoginData oidcLoginData = OidcLoginData.GetOidcLoginDataInstance();
            LoginResult   loginResult   = new LoginResult();
            bool          cancelPressed = false;

            if (oidcLoginData.AccessToken == null)
            {
                //Execute login
                loginResult = LoginHelper.DoLoginWithoutForm(out cancelPressed, false);
                if (!loginResult.IsSuccesfull)
                {
                    loginResult = LoginHelper.DoLogin(out cancelPressed);
                }

                if (loginResult.IsSuccesfull)
                {
                    return(EditRemark(loginResult, resultId, pathId, remark));
                }
                else if (!cancelPressed)
                {
                    TopMostMessageBox.Show("Unable to connect to server or user creadentials are invalid. Please verify data", "Log in problem");
                    return(ProjectScanStatuses.Error);
                }
            }
            else
            {
                loginResult.AuthenticationData = loginData;
                loginResult.IsSuccesfull       = true;
            }

            return(ProjectScanStatuses.CanceledByUser);
        }
예제 #2
0
        private LoginResult Login()
        {
            LoginResult loginResult = LoginHelper.DoLoginWithoutForm(out _cancelPressed, true);

            if (!loginResult.IsSuccesfull)
            {
                loginResult = LoginHelper.DoLogin(out _cancelPressed);
            }

            return(loginResult);
        }
        public static LoginResult LoginToServer()
        {
            LoginData     loginData     = LoginHelper.LoadSaved();
            OidcLoginData oidcLoginData = OidcLoginData.GetOidcLoginDataInstance();
            LoginResult   loginResult   = new LoginResult();
            bool          cancelPressed = false;

            if (oidcLoginData.AccessToken == null)
            {
                try
                {
                    loginResult = LoginHelper.DoLoginWithoutForm(out cancelPressed, false);
                    if (!loginResult.IsSuccesfull)
                    {
                        loginResult = LoginHelper.DoLogin(out cancelPressed);
                    }
                }
                catch (Exception e)
                {
                    Logger.Create().Error(e.ToString());
                    MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK);
                    return(null);
                }
            }
            else
            {
                loginResult.AuthenticationData = loginData;
                loginResult.IsSuccesfull       = true;
            }

            if (cancelPressed)
            {
                return(null);
            }
            if (!loginResult.IsSuccesfull)
            {
                if (!OIDCLoginHelper.errorWasShown)
                {
                    OIDCLoginHelper.errorWasShown = false;
                    showErrorMessage("Unable to connect to the server. Please verify data");
                    return(null);
                }
                return(LoginToServer());
            }
            return(loginResult);
        }
예제 #4
0
        static ProjectScanStatuses LoginAndBindSelectedProject(Entities.Project project)
        {
            OidcLoginData oidcLoginData = OidcLoginData.GetOidcLoginDataInstance();
            LoginData     loginData     = LoginHelper.LoadSaved();
            LoginResult   loginResult   = new LoginResult();
            bool          cancelPressed = false;

            if (oidcLoginData.AccessToken == null)
            {
                //Execute login
                loginResult = LoginHelper.DoLoginWithoutForm(out cancelPressed, false);
                if (!loginResult.IsSuccesfull)
                {
                    loginResult = LoginHelper.DoLogin(out cancelPressed);
                }
            }
            else
            {
                loginResult.AuthenticationData = loginData;
                loginResult.IsSuccesfull       = true;
            }

            if (loginResult.IsSuccesfull)
            {
                _canceled = false;
                BindSelectedProject(loginResult, project);
                if (!_canceled)
                {
                    return(ProjectScanStatuses.Success);
                }
                else
                {
                    return(ProjectScanStatuses.CanceledByUser);
                }
            }
            else if (!cancelPressed)
            {
                TopMostMessageBox.Show("Unable to connect to server.", "Log in problem");
                return(ProjectScanStatuses.Error);
            }

            return(ProjectScanStatuses.CanceledByUser);
        }
        private static LoginResult getLoginResult()
        {
            LoginData     loginData     = LoginHelper.LoadSaved();
            LoginResult   loginResult   = new LoginResult();
            OidcLoginData oidcLoginData = OidcLoginData.GetOidcLoginDataInstance();
            bool          cancelPressed;

            if (oidcLoginData.AccessToken == null)
            {
                loginResult = LoginHelper.DoLoginWithoutForm(out cancelPressed, false);
                if (!loginResult.IsSuccesfull)
                {
                    loginResult = LoginHelper.DoLogin(out cancelPressed);
                }
            }
            else
            {
                loginResult.AuthenticationData = loginData;
                loginResult.IsSuccesfull       = true;
            }

            return(loginResult);
        }