package org.yacos.web.system.form;

import java.util.Date;
import java.util.Random;

/**
 * 
 * @author christiancorsano
 *
 */
public class FormUser {
	private String login;
	private String email;
	private String password;
	private String passwordConfirm;
	private String firstName;
	private String lastName;
	private String organization;
	
	private String passwordPlaceholderValue;
	
	public FormUser() {
		this.login = "";
		this.email = "";
		
		// We can't use the real password of the user, so we generate
		//		a hopefully unique placeholder value, that we will be able to check for modification at validation
		Random placeholderSeed = new Random(new Date().getTime());
		this.passwordPlaceholderValue = "placeholder"+placeholderSeed.nextInt();
		
		this.password = this.passwordPlaceholderValue;
		this.passwordConfirm = this.passwordPlaceholderValue;
		this.firstName = "";
		this.lastName = "";
		this.organization = "";
	}
	/**
	 * @return the login
	 */
	public String getLogin() {
		return login;
	}
	/**
	 * @param login the login to set
	 */
	public void setLogin(String login) {
		this.login = login;
	}
	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}
	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}
	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	/**
	 * @return the passwordConfirm
	 */
	public String getPasswordConfirm() {
		return passwordConfirm;
	}
	/**
	 * @param passwordConfirm the passwordConfirm to set
	 */
	public void setPasswordConfirm(String passwordConfirm) {
		this.passwordConfirm = passwordConfirm;
	}
	/**
	 * @return the firstName
	 */
	public String getFirstName() {
		return firstName;
	}
	/**
	 * @param firstName the firstName to set
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	/**
	 * @return the lastName
	 */
	public String getLastName() {
		return lastName;
	}
	/**
	 * @param lastName the lastName to set
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	/**
	 * @return the organization
	 */
	public String getOrganization() {
		return organization;
	}
	/**
	 * @param organization the organization to set
	 */
	public void setOrganization(String organization) {
		this.organization = organization;
	}
	public boolean passwordWasModified() {
		return this.passwordPlaceholderValue.equals(this.getPassword());
	}
	public boolean passwordsMatches() {
		return this.password.equals(this.passwordConfirm);
	}
	
	
}
