Package reseter

Examples of reseter.PasswordReseter


        }
    }

    public String sendReseter(String adressToRedirect) {
        forgot = false;
        PasswordReseter passwordRecoverer = new PasswordReseter();
        String uniqueString = passwordRecoverer.getUniqueString();


        ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance()
                .getExternalContext().getContext();

        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance()
                .getExternalContext().getRequest();

        StringBuffer urlBuffered = request.getRequestURL();

        String url = urlBuffered.append("?string=").append(uniqueString)
                .toString().replace("logIn.xhtml", "reseter.xhtml");

        UserAccount userAccount = userAccountDAO.findByMail(enteredMail);

        if(userAccount == null) {
            FacesContext.getCurrentInstance().addMessage("logInForm:enteredPassword", new FacesMessage(FacesMessage.SEVERITY_FATAL,
                    "Aw!", "It wasn't funny."));
            return null;
        }



        try {
            userAccount.setPasswordRecoveryString(uniqueString);
            userAccountDAO.update(userAccount);
        } catch(Exception e) {
            FacesContext.getCurrentInstance().addMessage("logInForm:enteredPassword", new FacesMessage(FacesMessage.SEVERITY_FATAL,
                    "Ups!", "Something went terribly wrong. We're working on that."));
            return null;

        }


        passwordRecoverer.sendMailViaSSL(userAccount.getMail(), url);

        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,
                "Hey!", "Check Your mail."));
        return adressToRedirect;
View Full Code Here

TOP

Related Classes of reseter.PasswordReseter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.