All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.jhonsapp.bootstrap.user.model.AbstractUser Maven / Gradle / Ivy

package br.com.jhonsapp.bootstrap.user.model;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

import org.springframework.util.StringUtils;

import br.com.jhonsapp.bootstrap.util.CodeGenerator;

/**
 * {@link AbstractUser} is a abstract implementation of {@link User}
 * 
 * @see User
 * 
 * @author Jhonathan Camacho
 * @author Jhonys Camacho
 *
 */
@MappedSuperclass
public abstract class AbstractUser implements User {

	/**
	 * Generated serial version id created at 21 April 2017.
	 */
	private static final long serialVersionUID = 3307423139550627963L;

	@Column(name = "reset_password_code")
	private String resetPasswordCode;

	public AbstractUser() {
		super();
	}

	@Override
	public String getResetPasswordCode() {
		if (!StringUtils.hasText(resetPasswordCode))
			resetPasswordCode = CodeGenerator.generateCode(6);

		return resetPasswordCode;
	}

	@Override
	public void clearResetPasswordCode() {
		resetPasswordCode = "";
	}
	
	@Override
	public boolean isValidResetPasswordCode(String code){
		
		return StringUtils.hasText(resetPasswordCode) && resetPasswordCode.equals(code)? true : false;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy