Changeset 25129


Ignore:
Timestamp:
2012-02-22T10:30:17+13:00 (12 years ago)
Author:
sjm84
Message:

If the user enters in an incorrect username or password an appropriate error is produced

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java

    r25128 r25129  
    719719                request.logout();
    720720            }
    721             request.login(username[0], password[0]);
    722         }
    723 
     721           
     722            try
     723            {
     724                request.login(username[0], password[0]);
     725            }
     726            catch(Exception ex)
     727            {
     728                //The user entered in either the wrong username or the wrong password
     729                Element loginPageMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
     730                Element loginPageRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PAGE, "", userContext);
     731                loginPageRequest.setAttribute(GSXML.ACTION_ATT, "p");
     732                loginPageRequest.setAttribute(GSXML.SUBACTION_ATT, "login");
     733                loginPageRequest.setAttribute(GSXML.OUTPUT_ATT, "html");
     734                loginPageMessage.appendChild(loginPageRequest);
     735
     736                Element paramList = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     737                loginPageRequest.appendChild(paramList);
     738
     739                Element messageParam = this.doc.createElement(GSXML.PARAM_ELEM);
     740                messageParam.setAttribute(GSXML.NAME_ATT, "loginMessage");
     741                messageParam.setAttribute(GSXML.VALUE_ATT, "Either your username or password was incorrect, please try again.");
     742                paramList.appendChild(messageParam);
     743
     744                Element urlParam = this.doc.createElement(GSXML.PARAM_ELEM);
     745                urlParam.setAttribute(GSXML.NAME_ATT, "redirectURL");
     746                urlParam.setAttribute(GSXML.VALUE_ATT, this.getServletName() + "?" + request.getQueryString().replace("&", "&"));
     747                paramList.appendChild(urlParam);
     748
     749                Node loginPageResponse = this.recept.process(loginPageMessage);
     750                out.println(this.converter.getPrettyString(loginPageResponse));
     751
     752                return;
     753            }
     754        }
     755
     756        //If a user is logged in
    724757        if (request.getAuthType() != null)
    725758        {
Note: See TracChangeset for help on using the changeset viewer.