Ejemplo n.º 1
0
        static LoginResult TryDoLogin(out bool cancelPressed, bool relogin, bool showForm)
        {
            cancelPressed = false;

            //TODO check what to do with this
            if (_isLogged && !relogin)
            {
                _loginResult.AuthenticationData = LoadSaved();
                return(_loginResult);
            }

            LoginData login = null;

            if (_dispatcher == null)
            {
                _dispatcher = ServiceLocators.ServiceLocator.GetDispatcher();
            }

            if (_dispatcher != null)
            {
                login = LoadSaved();

                // verify that user hasn't active session and dialog data was validated sucessfull
                //TODO check if isLogged neccessary
                if (!_isLogged || !login.CanLog() || relogin)
                {
                    if (showForm)
                    {
                        try
                        {
                            _dispatcher.Dispatch(login);
                        }
                        catch (Exception err)
                        {
                            Logger.Create().Error(err);
                        }
                    }
                }
            }
            login.IsLogging = true;
            LoginResult loginResult = ExecuteLogin(login, out cancelPressed, relogin);

            if (loginResult != null && loginResult.IsSuccesfull)
            {
                isScanner = loginResult.AuthenticationData.SaveSastScan;
            }

            _isLogged = !cancelPressed ? loginResult.IsSuccesfull : false;

            Helpers.LoginHelper.Save(login);

            _loginResult = loginResult;
            _loginResult.IsSuccesfull = _isLogged;

            return(loginResult);
        }