Skip to content

Commit

Permalink
Added the date verified when verifying an email address (#7101)
Browse files Browse the repository at this point in the history
Co-authored-by: Angel Montenegro <[email protected]>
  • Loading branch information
Camelia-Orcid and amontenegro authored Oct 9, 2024
1 parent 3b7017c commit bb4e101
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void addSourceToEmail(String sourceId, String email) {
@Transactional
@UpdateProfileLastModified
public boolean verifyEmail(String email) {
Query query = entityManager.createNativeQuery("update email set is_verified = true, is_current=true, last_modified=now() where trim(lower(email)) = trim(lower(:email))");
Query query = entityManager.createNativeQuery("update email set is_verified = true, is_current=true, last_modified=now(), date_verified=now() where trim(lower(email)) = trim(lower(:email))");
query.setParameter("email", email);
return query.executeUpdate() > 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
Expand All @@ -24,7 +25,8 @@ public class EmailEntity extends SourceAwareEntity<String> implements OrcidAware
private Boolean primary;
private Boolean current;
private Boolean verified;
private String visibility;
private String visibility;
private Date dateVerified;

@Override
@Id
Expand Down Expand Up @@ -90,6 +92,15 @@ public String getVisibility() {
public void setVisibility(String visibility) {
this.visibility = visibility;
}

@Column(name = "date_verified")
public Date getDateVerified() {
return dateVerified;
}

public void setDateVerified(Date dateVerified) {
this.dateVerified = dateVerified;
}

public static Map<String, EmailEntity> mapByLowerCaseEmail(Collection<EmailEntity> emailEntities) {
Map<String, EmailEntity> map = new HashMap<>();
Expand All @@ -109,5 +120,6 @@ public void clean() {
visibility= null;
verified = null;
visibility = null;
dateVerified = null;
}
}
1 change: 1 addition & 0 deletions orcid-persistence/src/main/resources/db-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,5 @@
<include file="/db/updates/create_dw_notification.xml" />
<include file="/db/updates/create_dw_profile_email_domain.xml" />
<include file="/db/updates/add_unique_constraint_external_id_disambiguated_org.xml" />
<include file="/db/updates/add_date_verified_to_email.xml" />
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">

<changeSet author="Camelia Dumitru"
id="ADD-DATE-VERIFIED-COLUMN-TO-EMAIL-TABLE">
<addColumn tableName="email">
<column name="date_verified" type="Timestamp">
<constraints nullable="true" />
</column>
</addColumn>
</changeSet>
</databaseChangeLog>

0 comments on commit bb4e101

Please sign in to comment.