Ignore:
Timestamp:
2012-09-29T13:24:20+12:00 (12 years ago)
Author:
xiao
Message:

operation PerformChangePassword, now uses modifyUserInfo instead of removeUser then addUser

File:
1 edited

Legend:

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

    r26233 r26272  
    1818import javax.mail.Session;
    1919import javax.mail.Transport;
     20import javax.mail.PasswordAuthentication;
    2021import javax.mail.internet.AddressException;
    2122import javax.mail.internet.InternetAddress;
     
    627628        else if (op.equals(PERFORM_RETRIEVE_PASSWORD))
    628629        {
    629 
     630           
    630631        }
    631632        else if (op.equals(PERFORM_CHANGE_PASSWORD))
    632633        {
     634            serviceNode.setAttribute("operation", PERFORM_CHANGE_PASSWORD);
    633635            String user_name = (String) paramMap.get("username");
    634636            String oldPassword = (String) paramMap.get("oldPassword");
     
    640642            }
    641643           
    642             String prevPassword = retrieveDataForUser(user_name, "password");           
    643            
    644             oldPassword = hashPassword(oldPassword);
    645             if (!oldPassword.equals(prevPassword))
     644            String prevPassword = retrieveDataForUser(user_name, "password");                       
     645            if (!hashPassword(oldPassword).equals(prevPassword))
    646646            {
    647647                addUserInformationToNode(user_name, serviceNode);
    648                 serviceNode.setAttribute("operation", PERFORM_CHANGE_PASSWORD);
    649648                GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_INCORRECT_PASSWORD), "Incorrect Password");
    650649                return result;
     
    659658            }
    660659           
    661             newPassword = hashPassword(newPassword);
    662                        
    663             //Get the info of the given user, except for password   
    664             String prevGroups = retrieveDataForUser(user_name, "groups");
    665             String prevStatus = retrieveDataForUser(user_name, "status");
    666             String comment = "password_changed_by_user";
    667             String prevEmail = retrieveDataForUser(user_name, "email");
    668            
    669             error = removeUser(user_name);
    670             if (error != NO_ERROR)
    671             {               
    672                 addUserInformationToNode(user_name, serviceNode);
    673                 serviceNode.setAttribute("operation", ACCOUNT_SETTINGS);
    674                 GSXML.addError(this.doc, result, _errorMessageMap.get(error));
    675                
    676                 return result;
    677             }
    678            
    679             error = addUser(user_name, newPassword, prevGroups, prevStatus, comment, prevEmail);
    680             if (error != NO_ERROR)
    681             {
    682                 GSXML.addError(this.doc, result, _errorMessageMap.get(error));
    683             }
    684            
    685             addUserInformationToNode(null, serviceNode);
    686             serviceNode.setAttribute("operation", LIST_USERS);
     660            String chpa_groups = retrieveDataForUser(user_name, "groups");
     661            String chpa_comment = "password_changed_by_user";
     662            String info = this._derbyWrapper.modifyUserInfo(user_name, hashPassword(newPassword), chpa_groups, null, chpa_comment, null);
     663            if(info != "succeed"){//see DerbyWrapper.modifyUserInfo
     664                GSXML.addError(this.doc, result, _errorMessageMap.get(info));
     665                return result;
     666            }
    687667        }
    688668        else if (op.equals(EDIT_USER))
Note: See TracChangeset for help on using the changeset viewer.