/** * Used to process form submission. * * @return Register Page on creation failure, Main page on success */ @OnEvent(value = EventConstants.SUCCESS, component = "registerForm") public Object createUser() { User user = new User(); user.setLogin(login); user.setPassword(password); user.setEmail(email); user.setAge(age); user.setAdminRights(admin); // Try to add a new user if (manager != null) { try { // Add user manager.addUser(user); // Set application state logged user loggedUser = user; } catch (Exception ex) { registerForm.recordError("Error while adding user."); return Register.class; } } else { registerForm.recordError("User Manager unavailable"); return this; } return Main.class; }
String onSuccess() throws RemoteException { try { visitor.setConfig(service.getSOInterfaceConfiguration(visitor.getId())); if (!visitor.getConfig().isLicenseAvailable()) { form.recordError(messages.get("license-expired-text")); return null; } if (!service.login(visitor.getId(), visitor.getPassword())) { form.recordError(messages.get("login-failed-message")); return null; } logout(); if (visitor.getLocale() == null) { visitor.setLocale(new Locale(visitor.getConfig().getDefaultLanguage())); } persistentLocale.set(visitor.getLocale()); setUser(visitor); // FIXME: commented out beccause some pages(eg, newsalesorder) requires an use coming // from a specific page(eg, customer/search). // if (sourcePage != null) { // return sourcePage; // } // A complete solution would be to define the relationships between pages // in some way, and use that to figure out which page to redirect to. However, // it's out of the scope of current requirement... . return "customer/search"; } finally { visitor = null; } }
/** Creates a new user. */ void onValidateFromRegisterForm() { if (!authenticator.signUp(name, password, repeatPassword, birthdate)) { registerForm.recordError(registerPasswordField, "Register failed."); } else { loggedInPerson = authenticator.isValid(name, password); if (loggedInPerson == null) { registerForm.recordError(registerPasswordField, "Login Failed! Try again separatly."); } } }
/** * Used to control if the user already exists just before form submission. * * @return Register Page if user already exists */ @OnEvent(value = EventConstants.VALIDATE, component = "registerForm") public void verifyIfUserAlreadyExists() { if (manager != null) { User ttcUser = manager.getUserByLogin(login); if (ttcUser != null) { registerForm.recordError("User already exists."); } } else { registerForm.recordError("User Manager unavailable"); } }
void onValidateFromForm() { Users users = new UsersImpl(); try { users.login(user, oldPassword); } catch (Exception e) { form.recordError(oldPasswordField, "Old password is not OK"); } logger.debug("Password1: *{}*, passwod2: *{}*", newPassword, verifyNewPassword); if (!newPassword.equals(verifyNewPassword)) { form.recordError(verifyNewPasswordField, "Passwords do not match"); } }
void onValidateFromLoginForm() { if (!loginForm.isValid()) { return; } try { userProfile = userService.login(loginName, password, false); } catch (InstanceNotFoundException e) { loginForm.recordError(messages.get("error-authenticationFailed")); } catch (IncorrectPasswordException e) { loginForm.recordError(messages.get("error-authenticationFailed")); } }
void onValidateForm() { try { getDateStuffService().changeDateStuff(_dateStuff); } catch (Exception e) { // Display the cause. In a real system we would try harder to get a user-friendly message. _form.recordError(ExceptionUtil.getRootCause(e)); } }
void onValidateForm() { provider.setUserDetailsService(userserve); provider.setPasswordEncoder(new ShaPasswordEncoder()); authtoken = new UsernamePasswordAuthenticationToken(fLogin, fpass); provider.setSaltSource(salt); Authentication token = null; try { token = provider.authenticate(authtoken); } catch (org.springframework.security.BadCredentialsException e) { loginform.recordError("Either the Username or Password is incorrect, Please try again."); return; } if (token.isAuthenticated()) { System.out.println("user has been authenticated"); this.user = userDAO.findByUsername(fLogin); SecurityContextHolder.getContext().setAuthentication(token); SavedRequest savedRequest = (SavedRequest) requestGlobals .getHTTPServletRequest() .getSession() .getAttribute(AbstractProcessingFilter.SPRING_SECURITY_SAVED_REQUEST_KEY); Session s = request.getSession(false); s.invalidate(); s = request.getSession(true); if (savedRequest != null) { url = null; try { url = new URL(savedRequest.getRequestURL()); } catch (MalformedURLException e) { System.out.println("malformed url:" + savedRequest.getRequestURI()); } } } else { // fpass = null; // fLogin = null; loginform.recordError("Either the Username or Password is incorrect, Please try again."); } }
public void fct(Form form) { System.out.println("@@@@@@@@@@@@"); form.recordError("MON ERREUR"); }
void onActionFromClear() { form.clearErrors(); }