Commit 4c38c530 by Nilu

Fix NPE in ForgotPassword. Remove company user reference and use NPO to maintain functionality

parent 7ff9bb59
<?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.DefineTableOperation">
<tableName factory="String">it_does_not_matter</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="" type="CLOB" nullable="true"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
text NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
clob NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
text NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT pk_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
...@@ -30,8 +30,9 @@ public class ForgotPasswordFP extends SaveFP ...@@ -30,8 +30,9 @@ public class ForgotPasswordFP extends SaveFP
HttpServletRequest request = submission.getRequest(); HttpServletRequest request = submission.getRequest();
ObjectTransaction objTran = process.getTransaction(); ObjectTransaction objTran = process.getTransaction();
Job job = (Job) process.getAttribute("Job"); Job job = (Job) process.getAttribute("Job");
CompanyUser tmpComUser = (CompanyUser) process.getAttribute("CompanyUser"); CompanyUserNPO tmpComUser = (CompanyUserNPO) request.getAttribute("CompanyUser");
String email = job != null ? job.getEmail() : (tmpComUser != null ? tmpComUser.getEmail() : null); String email = job != null ? job.getEmail() : (tmpComUser != null ? tmpComUser.getEmail() : null);
Map emailParams = null;
Debug.assertion(StringUtils.subBlanks(email) != null, "Email not avaialble"); Debug.assertion(StringUtils.subBlanks(email) != null, "Email not avaialble");
...@@ -55,11 +56,15 @@ public class ForgotPasswordFP extends SaveFP ...@@ -55,11 +56,15 @@ public class ForgotPasswordFP extends SaveFP
{ {
LogMgr.log(LOG, LogLevel.PROCESSING1, "Inside ForgotPasswordFP for send reset pasword link mail to ", email); LogMgr.log(LOG, LogLevel.PROCESSING1, "Inside ForgotPasswordFP for send reset pasword link mail to ", email);
Map emailParams; if(tmpComUser != null)
{
CompanyUser companyUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser); CompanyUser companyUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
if(companyUser != null) if(companyUser == null)
{ {
throw new BusinessException("Sorry, you are not an authorised user to access admin portal.");
}
if(companyUser.getForgotPasswordKey() == null) if(companyUser.getForgotPasswordKey() == null)
{ {
String resetCode = new RandomStringGen().generateHumanAlphaNum(DEFAULT_PASSWORD_LENGTH); String resetCode = new RandomStringGen().generateHumanAlphaNum(DEFAULT_PASSWORD_LENGTH);
...@@ -73,7 +78,7 @@ public class ForgotPasswordFP extends SaveFP ...@@ -73,7 +78,7 @@ public class ForgotPasswordFP extends SaveFP
+ "?id=" + companyUser.getID() + "?id=" + companyUser.getID()
+ "&key=" + companyUser.getForgotPasswordKey()).toMap(); + "&key=" + companyUser.getForgotPasswordKey()).toMap();
} }
else else if(job != null)
{ {
Candidate candidate = secUser.getExtension(Candidate.REFERENCE_Candidate); Candidate candidate = secUser.getExtension(Candidate.REFERENCE_Candidate);
...@@ -120,12 +125,6 @@ public class ForgotPasswordFP extends SaveFP ...@@ -120,12 +125,6 @@ public class ForgotPasswordFP extends SaveFP
throw new BusinessException("Sorry, we don't recognize that email address."); throw new BusinessException("Sorry, we don't recognize that email address.");
} }
//remove temporary object
if(tmpComUser!=null)
{
tmpComUser.delete();
}
return super.processForm(process, submission, params); return super.processForm(process, submission, params);
} }
...@@ -145,15 +144,15 @@ public class ForgotPasswordFP extends SaveFP ...@@ -145,15 +144,15 @@ public class ForgotPasswordFP extends SaveFP
HttpServletRequest request = submission.getRequest(); HttpServletRequest request = submission.getRequest();
Job job = (Job) process.getAttribute("Job"); Job job = (Job) process.getAttribute("Job");
CompanyUser companyUser = (CompanyUser) process.getAttribute("CompanyUser"); CompanyUserNPO companyUser = (CompanyUserNPO) request.getAttribute("CompanyUser");
if(job!=null) if(job != null)
{ {
BusinessObjectParser.assertFieldCondition(StringUtils.subBlanks(job.getEmail()) != null, job, Job.FIELD_Email, "mandatory", exceptions, true, request); BusinessObjectParser.assertFieldCondition(StringUtils.subBlanks(job.getEmail()) != null, job, Job.FIELD_Email, "mandatory", exceptions, true, request);
} }
else if(companyUser!=null) else if(companyUser != null)
{ {
BusinessObjectParser.assertFieldCondition(StringUtils.subBlanks(companyUser.getEmail()) != null, companyUser, CompanyUser.FIELD_Email, "mandatory", exceptions, true, request); BusinessObjectParser.assertFieldCondition(StringUtils.subBlanks(companyUser.getEmail()) != null, companyUser, CompanyUserNPO.FIELD_Email, "mandatory", exceptions, true, request);
} }
} }
} }
\ No newline at end of file
...@@ -93,19 +93,6 @@ public class CompanyUser extends BaseCompanyUser ...@@ -93,19 +93,6 @@ public class CompanyUser extends BaseCompanyUser
} }
public Boolean emailExists()
{
if(getEmail() != null)
{
SecUser user = SecUser.searchNAME(getTransaction(), getEmail().toLowerCase());
return user != null && user.getExtension(CompanyUser.REFERENCE_CompanyUser) != null;
}
return Boolean.FALSE;
}
public String getEmailAddressFromUser() public String getEmailAddressFromUser()
{ {
return StringUtils.isEmailAddress(getUser().getUserName()) ? getUser().getUserName() : getUser().getEmail(); return StringUtils.isEmailAddress(getUser().getUserName()) ? getUser().getUserName() : getUser().getEmail();
......
package performa.orm;
import oneit.security.SecUser;
public class CompanyUserNPO extends BaseCompanyUserNPO
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public CompanyUserNPO ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
public Boolean emailExists()
{
if(getEmail() != null)
{
SecUser user = SecUser.searchNAME(getTransaction(), getEmail().toLowerCase());
return user != null && user.getExtension(CompanyUser.REFERENCE_CompanyUser) != null;
}
return Boolean.FALSE;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="CompanyUserNPO" package="performa.orm" superclass="NonPersistentBO">
<IMPORT value="oneit.servlets.orm.*"/>
<TABLE name="it_does_not_matter" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Email" type="String" validators="Email" />
</TABLE>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
...@@ -47,16 +47,7 @@ ...@@ -47,16 +47,7 @@
<% <%
ORMProcessState process = (ORMProcessState) ProcessDecorator.getDefaultProcess(request); ORMProcessState process = (ORMProcessState) ProcessDecorator.getDefaultProcess(request);
ObjectTransaction objTran = process.getTransaction (); ObjectTransaction objTran = process.getTransaction ();
CompanyUser companyUser = (CompanyUser) process.getAttribute("CompanyUser"); CompanyUserNPO companyUser = CompanyUserNPO.createCompanyUserNPO(objTran);
if(companyUser==null)
{
companyUser = CompanyUser.createCompanyUser(objTran);
process.setAttribute("CompanyUser", companyUser);
%><%@include file="/saferedirect.jsp"%><%
}
%> %>
<oneit:form name="forgotPassword" method="post" enctype="multipart/form-data"> <oneit:form name="forgotPassword" method="post" enctype="multipart/form-data">
<oneit:dynInclude page="/extensions/applicantportal/inc/multifieldtext.jsp" data="<%= CollectionUtils.EMPTY_MAP%>"/> <oneit:dynInclude page="/extensions/applicantportal/inc/multifieldtext.jsp" data="<%= CollectionUtils.EMPTY_MAP%>"/>
......
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