public IResponse Execute(ICruiseRequest cruiseRequest)
        {
            Hashtable velocityContext = new Hashtable();
            string    userName        = cruiseRequest.Request.GetText("userName");
            string    template        = @"UserNameLogin.vm";

            if (!string.IsNullOrEmpty(userName))
            {
                try
                {
                    LoginRequest credentials = new LoginRequest(userName);
                    string       password    = cruiseRequest.Request.GetText("password");
                    if (!string.IsNullOrEmpty(password))
                    {
                        credentials.AddCredential(LoginRequest.PasswordCredential, password);
                    }
                    string sessionToken = farmService.Login(cruiseRequest.ServerName, credentials);
                    if (string.IsNullOrEmpty(sessionToken))
                    {
                        throw new CruiseControlException("Login failed!");
                    }
                    storer.StoreSessionToken(sessionToken);
                    template = "LoggedIn.vm";
                }
                catch (Exception error)
                {
                    velocityContext["errorMessage"] = error.Message;
                }
            }
            velocityContext["hidePassword"] = hidePassword;
            return(viewGenerator.GenerateView(template, velocityContext));
        }
Esempio n. 2
0
        public IResponse Execute(ICruiseRequest cruiseRequest)
        {
            Hashtable velocityContext = new Hashtable();
            string    sessionToken    = cruiseRequest.RetrieveSessionToken();

            if (!string.IsNullOrEmpty(sessionToken))
            {
                farmService.Logout(cruiseRequest.ServerName, sessionToken);
            }
            storer.StoreSessionToken(null);
            return(viewGenerator.GenerateView("LoggedOut.vm", velocityContext));
        }