Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the date verified when verifying an email address #7092

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading