Use email validator
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@54442 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
12f05d645f
commit
d0931d2a27
|
@ -7,6 +7,7 @@ import {ConnectHelper} from '../../../openaire
|
|||
|
||||
import {Email} from '../../../openaireLibrary/utils/email/email';
|
||||
import {Body} from '../../../openaireLibrary/utils/email/body';
|
||||
import {Validator} from '../../../openaireLibrary/utils/email/validator';
|
||||
|
||||
import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties';
|
||||
import {EmailService} from '../../../openaireLibrary/utils/email/email.service';
|
||||
|
@ -88,7 +89,7 @@ export class InviteComponent implements OnInit {
|
|||
+ '<br>The purpose of this dashboard is to gather, link & monitor the research results related to your community.</p><p>The community dashboard is part of the <a href="https://connect.openaire.eu/">OpenAIRE-Connect</a> project and currently is in BETA version.</p>';
|
||||
|
||||
// TODO move the initialisation
|
||||
this.body = {/*salutation: "Dear Sir/Madame,",*/ fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, /*closing: "Kind regards,",*/ signature: "OpenAIRE team", note: ""};
|
||||
this.body = {fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, signature: "OpenAIRE team", note: ""};
|
||||
this.email = {body: "", subject: "[OpenAIRE-Connect] " + community.title, recipients: []};
|
||||
this.recipients = "";
|
||||
|
||||
|
@ -132,7 +133,7 @@ export class InviteComponent implements OnInit {
|
|||
this.successfulSentMessage = res + " email sent successfully!";
|
||||
}
|
||||
|
||||
this.body = {/*salutation: "Dear Sir/Madame,",*/ fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, /*closing: "Kind regards,",*/ signature: "OpenAIRE team", note: ""};
|
||||
this.body = {fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, signature: "OpenAIRE team", note: ""};
|
||||
this.email = {body: "", subject: "[OpenAIRE-Connect] " + this.community.title, recipients: []};
|
||||
this.recipients = "";
|
||||
},
|
||||
|
@ -161,7 +162,7 @@ export class InviteComponent implements OnInit {
|
|||
|
||||
public validateEmails(): boolean {
|
||||
if (this.parseEmails()) {
|
||||
if (this.hasValidEmails()) {
|
||||
if (Validator.hasValidEmails(this.email.recipients)) {
|
||||
return this.areValid;
|
||||
}
|
||||
}
|
||||
|
@ -188,28 +189,6 @@ export class InviteComponent implements OnInit {
|
|||
return true;
|
||||
}
|
||||
|
||||
private hasValidEmails(): boolean {
|
||||
let length = this.email.recipients.length;
|
||||
|
||||
for(let i = 0; i < length; i++) {
|
||||
if (!this.emailValidator(this.email.recipients[i])){
|
||||
// TODO remove console message after final testing
|
||||
console.log("INVALID EMAIL");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// TODO remove console message after final testing
|
||||
console.log("ALL EMAILS ARE VALID");
|
||||
return true;
|
||||
}
|
||||
|
||||
private emailValidator(email : any): boolean {
|
||||
if (email.match("^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public composeEmail() {
|
||||
// this.email.subject = "[OpenAIRE-Connect] Community_name";
|
||||
this.email.body = this.formatEmailBody();
|
||||
|
@ -222,11 +201,12 @@ export class InviteComponent implements OnInit {
|
|||
fromMessageAndName = "<span>" + this.body.fromMessage + this.body.fromName + "</span>";
|
||||
}
|
||||
|
||||
let formattedEmail = "<div style='font-size:14px;'>" + /*+ this.body.salutation + "<br><br>" +*/
|
||||
this.body.paragraphs +
|
||||
"<p>" /*+ this.body.closing + "<br>"*/ + this.body.signature + fromMessageAndName + "<br>" +
|
||||
"<a href='https://www.openaire.eu'>www.openaire.eu</a>" + "</p></div>";
|
||||
|
||||
let formattedEmail = "<div style='font-size:14px;'>"
|
||||
+ this.body.paragraphs
|
||||
+ "<p>" + this.body.signature + fromMessageAndName + "<br>"
|
||||
+ "<a href='https://www.openaire.eu'>www.openaire.eu</a>"
|
||||
+ "</p>"
|
||||
+ "</div>";
|
||||
|
||||
return formattedEmail;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue