/** * Sends the current log in object to the EJB * * @return Will either return the user to the log in page (if creation was successful) OR will * return user back to the register page with an error message * @throws NoSuchAlgorithmException This error is thrown if the password encryption fails */ public String createUser() throws NoSuchAlgorithmException { if (!detentionTrackerBean.userExists(currentLogin.getUsername())) { // If new username does not already exists... detentionTrackerBean.createInitialLogin(currentLogin); return "login?faces-redirect=true"; } // else if it does already exists... displayMessage( "Username already exists OR you have entered incorrect characters (letters & numbers only!)"); return null; }
/** * Returns the number of non administrator accounts * * @return number of accounts */ public int amountOfNonAdminAccounts() { return detentionTrackerBean.allLoginsThatAreNotAdmin().size(); }
/** * This method uses a FacesContext to find the current person who is logged in. It then loads the * current login object from the EJB */ public void loadLogin() { FacesContext context = FacesContext.getCurrentInstance(); String username = context.getExternalContext().getUserPrincipal().getName(); currentLogin = detentionTrackerBean.getLogin(username); }