Commit 8d516bbc by Nilu

Email ingest feature

parent 06b98d82
......@@ -16,6 +16,9 @@
<column name="verification_key" type="String" nullable="true" length="10"/>
<column name="is_account_verified" type="Boolean" nullable="true"/>
<column name="google_address_text" type="String" nullable="true" length="300"/>
<column name="is_email_ingest" type="Boolean" nullable="true"/>
<column name="is_masked_email" type="Boolean" nullable="true"/>
<column name="known_as_alias" type="String" nullable="true" length="100"/>
<column name="test_input_id" type="Long" length="11" nullable="true"/>
<column name="user_id" type="Long" length="11" nullable="true"/>
</NODE>
......
......@@ -15,6 +15,9 @@ CREATE TABLE oneit_sec_user_extension (
verification_key varchar(10) NULL,
is_account_verified char(1) NULL,
google_address_text varchar(300) NULL,
is_email_ingest char(1) NULL,
is_masked_email char(1) NULL,
known_as_alias varchar(100) NULL,
test_input_id numeric(12) NULL,
user_id numeric(12) NULL
);
......
......@@ -16,6 +16,9 @@ CREATE TABLE oneit_sec_user_extension (
verification_key varchar2(10) NULL,
is_account_verified char(1) NULL,
google_address_text varchar2(300) NULL,
is_email_ingest char(1) NULL,
is_masked_email char(1) NULL,
known_as_alias varchar2(100) NULL,
test_input_id number(12) NULL,
user_id number(12) NULL
);
......
......@@ -16,6 +16,9 @@ CREATE TABLE oneit_sec_user_extension (
verification_key varchar(10) NULL,
is_account_verified char(1) NULL,
google_address_text varchar(300) NULL,
is_email_ingest char(1) NULL,
is_masked_email char(1) NULL,
known_as_alias varchar(100) NULL,
test_input_id numeric(12) NULL,
user_id numeric(12) NULL
);
......
package performa.form;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import oneit.business.content.Article;
import oneit.components.ParticipantInitialisationContext;
import oneit.email.ConfigurableArticleTemplateEmailer;
import oneit.email.ConfigurableEmailerException;
import oneit.logging.*;
import oneit.net.LoopbackHTTP;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.objstore.parser.BusinessObjectParser;
......@@ -19,13 +15,13 @@ import oneit.utils.*;
import performa.orm.*;
import performa.orm.types.RoleType;
import performa.utils.Utils;
import performa.utils.WebUtils;
public class SendVerificationMailFP extends SaveFP
{
private static final LoggingArea LOG = LoggingArea.createLoggingArea("SendVerificationLink");
protected ConfigurableArticleTemplateEmailer emailer;
protected ConfigurableArticleTemplateEmailer emailChangedMailer;
@Override
......@@ -133,62 +129,46 @@ public class SendVerificationMailFP extends SaveFP
}
else
{
sendVerificationMail(candidate, job, request);
request.setAttribute("nextPage", request.getAttribute("nextPage") + "&JobID=" + job.getID());
}
return super.processForm(process, submission, params);
}
@Override
public void init(ParticipantInitialisationContext context) throws InitialisationException
if(candidate.isTrue(candidate.getIsEmailIngest()))
{
super.init(context);
if(candidate.isTrue(candidate.getIsMaskedEmail()))
{
SecUser old = (SecUser) candidate.getUser().getEarliestBackup();
emailer = (ConfigurableArticleTemplateEmailer) (context.getSingleChild("AccountVerificationEmailer"));
if(CollectionUtils.equals(old.getEmail(), candidate.getUser().getEmail()))
{
throw new BusinessException("Please enter a valid email address");
}
// send email changed mail
Utils.sendMaskedEmailChangedMail(candidate, job, emailChangedMailer);
private void sendVerificationMail(Candidate candidate, Job job, HttpServletRequest request) throws BusinessException
{
if(!candidate.isTrue(candidate.getIsAccountVerified()))
candidate.getUser().setUserName(candidate.getUser().getEmail());
candidate.setIsMaskedEmail(false);
candidate.setKnownAsAlias(old.getEmail());
}
else
{
try
candidate.setIsAccountVerified(true);
}
}
else
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Sending verification mail from SendVerificationMailFP to :: ", candidate);
Article verificationArticle = WebUtils.getArticleByShortCut(candidate.getTransaction(), WebUtils.APPLICANT_ACCOUNT_VERIFICATION);
RandomStringGen random = new RandomStringGen();
Utils.sendVerificationMail(candidate, job, emailer, SendVerificationMailFP.class.getName());
}
//set verification key and send mail time
candidate.setVerificationKey(random.generateAlphaNum(6));
candidate.setVerificationMailSendDate(new Date());
}
String link = LoopbackHTTP.getRemoteAccessURL(request)
+ verificationArticle.getLink(request, CollectionUtils.EMPTY_MAP, "/")
+ "?id=" + job.getID()
+ "&key=" + job.getRandomKey()
+ "&aid=" + candidate.getID()
+ "&pin=" + candidate.getVerificationKey();
Map defaultParams = CollectionUtils.mapEntry("link", link).toMap();
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, candidate.getUser(), job);
return super.processForm(process, submission, params);
}
Utils.sendMail(emailer, transform, new String[]{candidate.getUser().getUserName()}, null, candidate);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Sent verification mail successfully from " + SendVerificationMailFP.class + " to :: ", candidate);
}
catch (ConfigurableEmailerException ex)
@Override
public void init(ParticipantInitialisationContext context) throws InitialisationException
{
LogMgr.log(LOG, LogLevel.SYSTEMERROR1, ex, "Error occured while sending mail for Candidate :: " + candidate);
super.init(context);
throw new BusinessException("We are unable to send mail. Please try again or contact Matchd for more details.");
}
}
else
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Call from " + SendVerificationMailFP.class + ". Account is already verified for candidate :: ", candidate);
}
emailer = (ConfigurableArticleTemplateEmailer) (context.getSingleChild("AccountVerificationEmailer"));
emailChangedMailer = (ConfigurableArticleTemplateEmailer) (context.getSingleChild("EmailChangedEmailer"));
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import java.util.Comparator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import oneit.logging.LoggingArea;
import oneit.objstore.MessageSource;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.rdbms.filters.EqualsFilter;
......@@ -25,6 +26,7 @@ import performa.utils.ExpressAnswerFilter;
public class Candidate extends BaseCandidate
{
public static LoggingArea LOG = LoggingArea.createLoggingArea("Candidate");
private static final long serialVersionUID = 0L;
// This constructor should not be called
......@@ -181,4 +183,9 @@ public class Candidate extends BaseCandidate
Distance calculateDistance = DistanceUtils.calculateDistance(FIELD_Phone, FIELD_Phone);
return false;
}
public boolean isUnverifiedEmailIngestUser()
{
return !isTrue(getIsAccountVerified()) && isTrue(getIsEmailIngest());
}
}
\ No newline at end of file
......@@ -23,6 +23,9 @@
<ATTRIB name="VerificationKey" type="String" dbcol="verification_key" length="10"/>
<ATTRIB name="IsAccountVerified" type="Boolean" dbcol="is_account_verified" defaultValue="Boolean.FALSE"/>
<ATTRIB name="GoogleAddressText" type="String" dbcol="google_address_text" length="300"/>
<ATTRIB name="IsEmailIngest" type="Boolean" dbcol="is_email_ingest" defaultValue="Boolean.FALSE"/>
<ATTRIB name="IsMaskedEmail" type="Boolean" dbcol="is_masked_email" defaultValue="Boolean.FALSE"/>
<ATTRIB name="KnownAsAlias" type="String" dbcol="known_as_alias" length="100"/>
<SINGLEREFERENCE name="TestInput" type="TestInput" dbcol="test_input_id" backreferenceName="Candidates" />
<SINGLEREFERENCE name="User" type="SecUser" dbcol="user_id" backreferenceName="Extensions" inSuper='TRUE'/>
......@@ -31,6 +34,10 @@
<SEARCH type="All" paramFilter="oneit_sec_user_extension.object_id is not null" >
</SEARCH>
<SEARCH type="Alias" filter="known_as_alias = ?" polymorphic="TRUE" singleton="TRUE">
<PARAM name="KnownAs" type="String"/>
</SEARCH>
<SEARCH type="IdPin" paramFilter="oneit_sec_user_extension.object_id is not null" singleton="TRUE">
<PARAM name="ID" type="Long" paramFilter="object_id = ${ID} " />
<PARAM name="Pin" type="String" paramFilter="verification_key = ${Pin}" />
......
......@@ -105,14 +105,14 @@ public class JobApplication extends BaseJobApplication
if(getCV() != null)
{
String contentType = getCV().getContentType();
context.check(contentType.contains("msword") || contentType.contains("opendocument.text")
context.check(contentType.contains("msword") || contentType.contains("doc") || contentType.contains("docx") || contentType.contains("opendocument.text")
|| contentType.contains("pdf") || contentType.contains("vnd.openxmlformats-officedocument.wordprocessingml.document") , this, FIELD_CV, "invalid");
}
if(getCoverLetter() != null)
{
String contentType = getCoverLetter().getContentType();
context.check(contentType.contains("msword") || contentType.contains("opendocument.text")
context.check(contentType.contains("msword") || contentType.contains("doc") || contentType.contains("docx") || contentType.contains("opendocument.text")
|| contentType.contains("pdf") || contentType.contains("vnd.openxmlformats-officedocument.wordprocessingml.document") , this, FIELD_CoverLetter, "invalid");
}
}
......
......@@ -43,8 +43,8 @@ public class Utils
public static final String PRIV_ACCESS_APPLICANT_PORTAL = "TL_AccessApplicantPortal";
public static final String PRIV_ACCESS_COMPANY_ADMIN = "TL_AccessCompanyAdmin";
public static final String PRIV_ACCESS_COMPANY = "TL_AccessCompany";
public static final String ADVT_CONFIG_EMAIL_EXTENSION = ConfigMgr.getKeyfileString ("advt.config.email.extension", "matchdmail.com");
public static final String APPLICANT_VERIFY_LINK = "/ApplicantPortal-Applicant_Account_Verification.htm";
public static Role getRole(String role, ObjectTransaction transaction)
{
......@@ -428,6 +428,48 @@ public class Utils
}
public static void sendVerificationMail(Candidate candidate, Job job, ConfigurableArticleTemplateEmailer emailer, String callingClass) throws BusinessException
{
if(!candidate.isTrue(candidate.getIsAccountVerified()))
{
try
{
LogMgr.log(Candidate.LOG, LogLevel.PROCESSING1, "Sending verification mail from SendVerificationMailFP to :: ", candidate);
RandomStringGen random = new RandomStringGen();
//set verification key and send mail time
candidate.setVerificationKey(random.generateAlphaNum(6));
candidate.setVerificationMailSendDate(new Date());
String link = LoopbackHTTP.getRemoteAccessURL()
+ APPLICANT_VERIFY_LINK
+ "?id=" + job.getID()
+ "&key=" + job.getRandomKey()
+ "&aid=" + candidate.getID()
+ "&pin=" + candidate.getVerificationKey();
Map defaultParams = CollectionUtils.mapEntry("link", link).toMap();
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, candidate.getUser(), job);
Utils.sendMail(emailer, transform, new String[]{candidate.getUser().getUserName()}, null, candidate);
LogMgr.log(Candidate.LOG, LogLevel.PROCESSING1, "Sent verification mail successfully from " + callingClass + " to :: ", candidate);
}
catch (ConfigurableEmailerException ex)
{
LogMgr.log(Candidate.LOG, LogLevel.SYSTEMERROR1, ex, "Error occured while sending mail for Candidate :: " + candidate);
throw new BusinessException("We are unable to send mail. Please try again or contact Matchd for more details.");
}
}
else
{
LogMgr.log(Candidate.LOG, LogLevel.PROCESSING1, "Call from " + callingClass + ". Account is already verified for candidate :: ", candidate);
}
}
public static void sendVerificationMail(Job job, CompanyUser companyUser, HttpServletRequest request, ConfigurableArticleTemplateEmailer emailer, String callingClass) throws BusinessException
{
if(!CollectionUtils.equals(companyUser.getIsAccountVerified(), Boolean.TRUE))
......@@ -468,6 +510,40 @@ public class Utils
}
public static void sendMaskedEmailChangedMail(Candidate candidate, Job job, ConfigurableArticleTemplateEmailer emailer) throws BusinessException
{
try
{
LogMgr.log(Candidate.LOG, LogLevel.PROCESSING1, "Sending masked email changed mail to :: ", candidate);
RandomStringGen random = new RandomStringGen();
//set verification key and send mail time
candidate.setVerificationKey(random.generateAlphaNum(6));
candidate.setVerificationMailSendDate(new Date());
String link = LoopbackHTTP.getRemoteAccessURL()
+ APPLICANT_VERIFY_LINK
+ "?id=" + job.getID()
+ "&key=" + job.getRandomKey()
+ "&aid=" + candidate.getID()
+ "&pin=" + candidate.getVerificationKey();
Map defaultParams = CollectionUtils.mapEntry("link", link).toMap();
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, candidate.getUser(), job);
Utils.sendMail(emailer, transform, new String[]{candidate.getUser().getEmail()}, null, candidate);
LogMgr.log(CompanyUser.LOG, LogLevel.PROCESSING1, "Sent masked email changed mail successfully to :: ", candidate);
}
catch (ConfigurableEmailerException ex)
{
LogMgr.log(CompanyUser.LOG, LogLevel.SYSTEMERROR1, ex, "Error occured while sending mail for user :: " + candidate);
throw new BusinessException("We are unable to send mail. Please try again or contact Matchd for more details.");
}
}
public static void sendEmailChangedMail(CompanyUser companyUser, HttpServletRequest request, ConfigurableArticleTemplateEmailer emailer, String callingClass) throws BusinessException
{
if(companyUser.getIsEmailChanged()==Boolean.TRUE)
......
......@@ -13,6 +13,7 @@
<FORM name="*.saveAndExitWorkStyle" factory="Participant" class="performa.form.SaveAndExitWorkStypeFP"/>
<FORM name="*.sendVerificationMail" factory="Participant" class="performa.form.SendVerificationMailFP">
<AccountVerificationEmailer factory="Participant" class="oneit.email.ConfigurableArticleTemplateEmailer" templateShortcut="AccountVerificationMail"/>
<EmailChangedEmailer factory="Participant" class="oneit.email.ConfigurableArticleTemplateEmailer" templateShortcut="EmailChangedMail"/>
</FORM>
<FORM name="*.facebookOAuthLogin" factory="Participant" class="oneit.security.oauth.form.FacebookOAuthLoginFP"/>
<FORM name="*.googleOAuthLogin" factory="Participant" class="oneit.security.oauth.form.GoogleOAuthLoginFP"/>
......
......@@ -53,9 +53,20 @@
Debug.assertion(job != null && !toRedirect, "Invalid job in applicant portal");
Debug.assertion(candidate != null, "Invalid candidate in applicant portal");
Article applyJobArticle = WebUtils.getArticleByShortCut(objTran, WebUtils.APPLY_JOB);
String confirmDetailsPage = LoopbackHTTP.getRemoteAccessURL(request)
+ applyJobArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", "VerifyIdentity").toMap(), "/");
if(candidate.isUnverifiedEmailIngestUser() && candidate.getKnownAsAlias() == null)
{
request.getSession().setAttribute (SecUser.SEC_USER_ID, secUser);
request.getSession().setAttribute (SessionSecUserDecorator.REFRESH_SECURITY, Boolean.TRUE);
response.sendRedirect(confirmDetailsPage + "&JobID=" + job.getID().toString());
}
JobApplication jobApplication = JobApplication.searchCandidateJob(transaction, candidate, job);
Article applyJobArticle = WebUtils.getArticleByShortCut(objTran, WebUtils.JOB_APPLICATION);
String nextPage = applyJobArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", job.getIncludeAssessmentCriteria() ? "SelectionCriteria" : "WorkplaceCulture").toMap());
Article jobApplicationArticle = WebUtils.getArticleByShortCut(objTran, WebUtils.JOB_APPLICATION);
String nextPage = jobApplicationArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", job.getIncludeAssessmentCriteria() ? "SelectionCriteria" : "WorkplaceCulture").toMap());
process.setAttribute("JobApplication", jobApplication);
%>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.RedefineTableOperation">
<tableName factory="String">oneit_sec_user_extension</tableName>
<column name="is_email_ingest" type="Boolean" nullable="true"/>
<column name="is_masked_email" type="Boolean" nullable="true"/>
<column name="known_as_alias" type="String" nullable="true" length="100"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
......@@ -5,23 +5,30 @@
<oneit:dynIncluded>
<%
Candidate candidate = (Candidate) process.getAttribute("NewCandidate");
ObjectTransaction objTran = process.getTransaction ();
boolean toRedirect = GenericObjDF.getOrCreateObject (request, "Job", Job.REFERENCE_Job);
Job job = (Job) process.getAttribute("Job");
String successPage = WebUtils.getSamePageInRenderMode(request, "VerificationSent");
SecUser secUser = null;
boolean toRedirect = false;
if(candidate != null)
Debug.assertion(job != null && !toRedirect, "Invalid job in applicant portal");
Candidate candidate = (Candidate) process.getAttribute("NewCandidate");
SecUser secUser = SecUser.getTXUser(transaction);
if(candidate == null && secUser != null)
{
candidate = secUser.getExtension(Candidate.REFERENCE_Candidate);
}
if(secUser == null && candidate != null)
{
secUser = candidate.getUser();
process.setAttribute("NewCandidate", candidate);
}
Debug.assertion(job != null && !toRedirect, "Invalid job in applicant portal");
Debug.assertion(candidate != null, "Invalid candidate in applicant portal");
String successPage = WebUtils.getSamePageInRenderMode(request, "VerificationSent") + "&JobID=" + job.getID();
String applyJobPage = WebUtils.getArticleByShortCut(transaction, WebUtils.JOB_APPLICATION).getLink(request) + "?JobID=" + job.getID();
JobApplication jobApplication = JobApplication.searchCandidateJob(transaction, candidate, job);
String nextPage = WebUtils.getSamePageInRenderMode(request, "Page");
if(jobApplication == null)
{
......@@ -129,7 +136,20 @@
<div class="main-box-layout main-verify-step-2">
<div class="form-group text-left">
<label>Email Address</label>
<%
if(candidate.isUnverifiedEmailIngestUser() && candidate.isTrue(candidate.getIsMaskedEmail()))
{
%>
<oneit:ormInput obj="<%= secUser %>" type="text" attributeName="Email" cssClass="form-control" style="text-transform: lowercase" required="true"/>
<%
}
else
{
%>
<oneit:ormInput obj="<%= secUser %>" type="text" attributeName="Email" cssClass="form-control second-style" disabled="true" readonly="true"/>
<%
}
%>
</div>
<div class="form-group text-left email">
......@@ -245,7 +265,21 @@
</div>
</div>
<div class="text-center">
<%
if(candidate.isUnverifiedEmailIngestUser() && !candidate.isTrue(candidate.getIsMaskedEmail()))
{
%>
<oneit:button value="Verify and proceed" name="sendVerificationMail" cssClass="box-btn send-link-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", applyJobPage)
.mapEntry("Job",job)
.mapEntry("Candidate",candidate)
.mapEntry("JobApplication",jobApplication)
.toMap() %>"/>
<%
}
else
{
%>
<oneit:button value="Submit" name="sendVerificationMail" cssClass="box-btn send-link-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", successPage)
.mapEntry("Job",job)
......@@ -253,6 +287,9 @@
.mapEntry("JobApplication",jobApplication)
.mapEntry(NotificationUtils.NOTIFICATION_MSG_PARAM, "emailSent")
.toMap() %>"/>
<%
}
%>
</div>
</div>
</div>
......
......@@ -32,15 +32,17 @@
<MAP value="HOME_TL" description="HomePage" JSP="/extensions/performa/editor/additionalHomePage.jsp" />
</NODE>
<!-- <NODE name="WEB_BATCH::Email">
<NODE name="WEB_BATCH::Email">
<TASK factory="Participant" class="oneit.appservices.batch.DefaultTask">
<RUN class="performa.utils.PerformaEmailFetcher" factory="Participant" />
<RUN class="performa.utils.PerformaEmailFetcher" factory="Participant">
<AccountVerificationEmailer factory="Participant" class="oneit.email.ConfigurableArticleTemplateEmailer" templateShortcut="AccountVerificationMail"/>
</RUN>
<WHEN factory="MetaComponent" component="BatchSchedule" selector="performa.runbatch">
<NODE name="schedule" class="oneit.appservices.batch.QuickSchedule">
<NODE name="period" factory="Integer" value="5"/>
</NODE>
</WHEN>
</TASK>
</NODE>-->
</NODE>
</OBJECTS>
\ No newline at end of file
<%@ page import="performa.orm.*, performa.orm.types.*, performa.form.*, performa.utils.*, performa.search.*"%>
<%@ page import="com.stripe.model.*"%>
<%@ page import="oneit.objstore.rdbms.filters.*, oneit.security.jsp.SecUserToNameTransform, oneit.servlets.utils.*, oneit.utils.image.*, oneit.objstore.utils.ObjstoreUtils "%>
<%@ page import="oneit.utils.text.FormatUtils, oneit.utils.math.*"%>
<%@ page import="oneit.objstore.rdbms.filters.*, oneit.servlets.security.SessionSecUserDecorator, oneit.security.jsp.SecUserToNameTransform, oneit.servlets.utils.*, oneit.utils.image.*, oneit.objstore.utils.ObjstoreUtils "%>
<%@ page import="oneit.utils.text.FormatUtils, oneit.utils.math.*, oneit.net.LoopbackHTTP"%>
<%@ page import="oneit.servlets.objstore.binary.*,oneit.servlets.jsp.ormtable.*"%>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment