-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed emails templates and link from application validation expirat…
…ion time Co-authored-by: Daniel Ferreira <[email protected]>
- Loading branch information
1 parent
0bd0830
commit 709babb
Showing
13 changed files
with
82 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ JWT_SECRET=Lendas contam que o Rui foi membro do IEEE. | |
# Frontend Password Recovery Base Route | ||
PASSWORD_RECOVERY_LINK=https://localhost:3000/recover | ||
|
||
# Froantend Application Confirmation Base Route | ||
APPLICATION_CONFIRMATION_LINK=https://localhost:8087/apply/company/validate/ | ||
# Frontend Application Confirmation Base Route | ||
APPLICATION_CONFIRMATION_LINK=https://localhost:3000/apply/company/validate/ | ||
|
||
# Specifies the port in which the app will be exposed | ||
PORT=8087 | ||
|
@@ -36,17 +36,17 @@ TEST_LOG_REQUESTS=false | |
ADMIN_EMAIL=[email protected] | ||
ADMIN_PASSWORD=n1j0bs_ftw.12345 | ||
#CORS allowed origin - OVERRIDE IN PRODUCTION | ||
ACCESS_CONTROL_ALLOW_ORIGIN= | ||
ACCESS_CONTROL_ALLOW_ORIGIN=https://localhost | ||
|
||
# Mail service information. If you don't provide a MAIL_FROM, no emails will be sent. The app will execute no-ops and won't crash | ||
# However, if you want to send emails, you need to fill all of the following 2 fields | ||
# Check this for details on how to configure your personal account for testing (https://support.google.com/accounts/answer/185833?p=InvalidSecondFactor&visit_id=637446218993181653-2339409452&rd=1) | ||
|
||
# The email address from which the emails are sent | ||
MAIL_FROM=[email protected] | ||
MAIL_FROM= | ||
|
||
# Password for email above | ||
MAIL_FROM_PASSWORD=PgAnnVsAa6Sg8zJp6t | ||
MAIL_FROM_PASSWORD= | ||
|
||
# Cloudinary API URL to save images | ||
CLOUDINARY_URL= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
import CompanyApplication, { CompanyApplicationRules } from "../../models/CompanyApplication.js"; | ||
import { APIError, ErrorTypes } from "./errorHandler.js"; | ||
import { StatusCodes as HTTPStatus } from "http-status-codes/build/cjs/status-codes.js"; | ||
export const exceededCreationTimeLimit = async (email) => { | ||
const cursor = await CompanyApplication.findOne({ email, isVerified: false }).exec(); | ||
if (cursor !== null && Date.now() - cursor.submittedAt < 5000 * 60) { | ||
throw new APIError(HTTPStatus.FORBIDDEN, ErrorTypes.FORBIDDEN, CompanyApplicationRules.APPLICATION_RECENTLY_CREATED); | ||
} | ||
return true; | ||
}; | ||
import { VALIDATION_LINK_EXPIRATION } from "../../models/constants/ApplicationStatus.js"; | ||
import { SECOND_IN_MS } from "../../models/constants/TimeConstants.js"; | ||
|
||
export const deleteApplications = async (email) => { | ||
await CompanyApplication.deleteMany({ email: email, isVerified: false }).catch(function(error) { | ||
console.error(error); | ||
throw (error); // Failure | ||
}); | ||
export const exceededCreationTimeLimit = async (req, res, next) => { | ||
const application = await CompanyApplication.findOne({ email: req.body.email, isVerified: false }); | ||
if (application !== null && Date.now() < application.submittedAt.getTime() + (VALIDATION_LINK_EXPIRATION * SECOND_IN_MS)) { | ||
return next(new APIError(HTTPStatus.FORBIDDEN, ErrorTypes.FORBIDDEN, CompanyApplicationRules.APPLICATION_RECENTLY_CREATED.msg)); | ||
} | ||
return next(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<h1>Confirm your NIJobs application</h1> | ||
<p>Please follow this <a href="{{link}}" target="_blank">link</a> to finish the process. Note that the link will be expired in 5 minutes.</p> | ||
<p>We have successfully received your application!</p> | ||
<p>Please follow this <a href="{{link}}" target="_blank">link</a> to finish the process. Note that the link will expire in 10 minutes.</p> | ||
<br> | ||
<p>If you did not request this or need anything else, please contact us at <a href="mailto:[email protected]">[email protected]</a>!</p><br> | ||
<p>Sincerely,</p> | ||
|
7 changes: 4 additions & 3 deletions
7
src/email-templates/new_company_application_company.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<h1>We have successfully received your application!</h1> | ||
<p>We will now review your application, and in case you're approved, you will receive another email with further instructions in order to complete your registration.</p> | ||
<h1>Your application has been validated!</h1> | ||
<p>We will now review your application, and in case you're approved, you will receive another email with further instructions in order to complete your registration.</p> | ||
<p>Your Application ID is {{applicationId}} and you registered {{companyName}}</p> | ||
<p>Once you're approved, you will receive an email, and then you can log into NIJobs! Do not forget your password, you will need it on the first login.</p> | ||
<br> | ||
<p>If you did not request this or if you need anything else, don't hesitate to contact us at <a href="mailto:[email protected]">[email protected]</a>!</p> | ||
<br> | ||
<p>Sincerely,</p> | ||
<p>NIJobs team at NIAEFEUP</p> | ||
<p>NIJobs team at NIAEFEUP</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,9 @@ | ||
import jwt from "jsonwebtoken"; | ||
import { APIError, ErrorTypes } from "../api/middleware/errorHandler.js"; | ||
import { StatusCodes as HTTPStatus } from "http-status-codes/build/cjs/status-codes.js"; | ||
import ValidationReasons from "../api/middleware/validators/validationReasons.js"; | ||
|
||
export const generateToken = (data, secret, expiresInSeconds) => jwt.sign( | ||
{ ...data }, | ||
secret, | ||
{ expiresIn: `${expiresInSeconds} seconds`, algorithm: "HS256" } | ||
); | ||
|
||
export const verifyAndDecodeToken = (token, secret, next) => { | ||
try { | ||
return jwt.verify(token, secret, { algorithm: "HS256" }); | ||
} catch (jwtErr) { | ||
if (jwtErr.name === "TokenExpiredError") { | ||
return next(new APIError(HTTPStatus.FORBIDDEN, ErrorTypes.FORBIDDEN, ValidationReasons.EXPIRED_TOKEN)); | ||
} else { | ||
return next(new APIError(HTTPStatus.FORBIDDEN, ErrorTypes.FORBIDDEN, ValidationReasons.INVALID_TOKEN)); | ||
} | ||
} | ||
}; | ||
export const verifyAndDecodeToken = (token, secret) => jwt.verify(token, secret, { algorithm: "HS256" }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters