From b3c584412f9b52b3dd91e7feb47f148b558627d2 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 12 Mar 2016 18:38:23 +0100 Subject: [PATCH] Email changing is only possible with a cryptographic hash ... opps --- .../email_address/ChangeableEmailAddress.java | 14 +++++++++++ .../email_address/EmailAddressChange.java | 25 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/org/mxchange/jusercore/model/email_address/ChangeableEmailAddress.java b/src/org/mxchange/jusercore/model/email_address/ChangeableEmailAddress.java index a672c2b..c6fd7de 100644 --- a/src/org/mxchange/jusercore/model/email_address/ChangeableEmailAddress.java +++ b/src/org/mxchange/jusercore/model/email_address/ChangeableEmailAddress.java @@ -113,6 +113,20 @@ public interface ChangeableEmailAddress extends Serializable { */ void setEmailChangeStatus (final EmailChangeStatus emailChangeStatus); + /** + * Getter for email change hash + *

+ * @return Email change hash + */ + String getEmailChangeHash (); + + /** + * Getter for email change hash + *

+ * @param emailChangeHash Email change hash + */ + void setEmailChangeHash (final String emailChangeHash); + @Override boolean equals (final Object object); diff --git a/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java b/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java index e3c4225..1531630 100644 --- a/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java +++ b/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java @@ -27,6 +27,7 @@ import javax.persistence.Enumerated; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; @@ -44,7 +45,12 @@ import org.mxchange.jusercore.model.user.User; * @author Roland Haeder */ @Entity (name = "email_changes") -@Table (name = "email_changes") +@Table ( + name = "email_changes", + indexes = { + @Index (name = "hash", columnList = "email_change_hash", unique = true) + } +) @NamedQueries ( @NamedQuery (name = "SearchEmailChangeByEmail", query = "SELECT e FROM email_changes AS e WHERE LOWER(e.emailAddress) LIKE LOWER(:email)") ) @@ -78,6 +84,13 @@ public class EmailAddressChange implements ChangeableEmailAddress { @Column (name = "email_change_done", nullable = false, updatable = false) private Calendar emailChangeDone; + /** + * Email change hash the user has to click + */ + @Basic (optional = false) + @Column (name = "email_change_hash", unique = true) + private String emailChangeHash; + /** * Email change id */ @@ -183,6 +196,16 @@ public class EmailAddressChange implements ChangeableEmailAddress { this.emailChangeDone = emailChangeDone; } + @Override + public String getEmailChangeHash () { + return this.emailChangeHash; + } + + @Override + public void setEmailChangeHash (final String emailChangeHash) { + this.emailChangeHash = emailChangeHash; + } + @Override public Long getEmailChangeId () { return this.emailChangeId; -- 2.39.5