NIAEFEUP / nijobs-be

[BACKEND] A platform for companies to advertise their job opportunities to students
GNU General Public License v3.0
18 stars 3 forks source link

224 confirmation email when companies register #306

Open FranciscoCardoso913 opened 1 year ago

FranciscoCardoso913 commented 1 year ago

Confirmation email when companies register

Important:

Although this is a back-end issue it also has changes in the Front-End! See the changes made in the Front-End here: https://github.com/NIAEFEUP/nijobs-fe/pull/309

Issue: https://github.com/NIAEFEUP/nijobs-be/issues/224

Discussed solution:

-When created, applications should have a state UNVERIFIED by default instead of the current PENDING state;

-After creating an application an email with a link should be sent to the company so they can validate their application, the link should expire in 10 minutes;

-A company should not be able to create an application with an email associated with an UNVERIFIED application whose link is yet to expire;

-If the link of an application expires and the company tries to create another application the previous application of that company should be deleted;

-The link should send the user to a page where the application is validated, when validating the application its state should change to pending and an email should be sent to the company.

Back-End changes:

-The application model now has a new attribute called "isVerified" which indicates if the application has already been validated or not by the company, the attribute is set to false when the application is created;

-There is a new application state, an application is UNVERIFIED when the isVerified is false, and PENDING when isVerified is true and both of the approvedAt and the rejectedAt are null;

-Before creating a new application the Back-End now checks if an application with the same email as the new application had been created in less than 10 minutes from the time the request for a new application is sent, if so the Back-End returns an error to the Front-End, otherwise, the Back-End deletes the old application( if it exists) and creates a new one;

-If the Front-End requests it the Back-End validates the application, returning an error if for some reason the validation is illegal (token has expired, the token is not valid, the application is already validated, etc...) ;

-Emails have been changed! Now when a new application is created a single email with a link is sent to the company, only after the application is validated that two other emails are sent, one of them sent to the NIJobs team informing that a company has created a new application and the other sent to the company to inform that everything went well and that we will review their request.

-The function verifyAndDecodeToken now returns a different error when the token expires and when the token is invalid, unlike before when the error returned was the same;

Emails new order:

-The first email which is sent to the company when the application is created:

Screenshot from 2023-02-11 23-06-16

-The second email sent to the NiJobs team when the application is validated.

Screenshot from 2023-02-11 23-07-30

-The third email which is sent to the company after the application is validated.

Screenshot from 2023-02-11 23-08-37

What is yet to be done:

-Tests;

Doubts:

-Should we change any of the email's text/order?

-Did we use the API errors correctly or should we have done something differently?

-Is everything in the correct place or is there anything that is more adequate somewhere else?

-Should the UNVERIFIED applications, which can no longer be verified, be deleted automatically from time to time or should we let it be like it is now (it's only deleted when a new application with the same email is created  )?
render[bot] commented 1 year ago

Your Render PR Server URL is https://nijobs-be-pr-306.onrender.com.

Follow its progress at https://dashboard.render.com/web/srv-cfk2gnhgp3jgtsvl5cu0.

FranciscoCardoso913 commented 1 year ago

New workflow

Discussed solution

Naapperas commented 1 year ago

@FranciscoCardoso913 @dsantosferreira Updates on this?

codecov[bot] commented 1 year ago

Codecov Report

Attention: Patch coverage is 90.82569% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 90.55%. Comparing base (82886d0) to head (4f35451).

Files Patch % Lines
src/services/application.js 88.23% 4 Missing :warning:
src/api/routes/application.js 83.33% 2 Missing :warning:
src/api/routes/company.js 77.77% 2 Missing :warning:
src/services/company.js 60.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #306 +/- ## =========================================== + Coverage 90.34% 90.55% +0.21% =========================================== Files 54 55 +1 Lines 1470 1546 +76 Branches 246 257 +11 =========================================== + Hits 1328 1400 +72 - Misses 137 141 +4 Partials 5 5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Naapperas commented 6 months ago

Some of the comments appear outdated and I don't know why: when I open the respective files nothing changed. Please resolve or answer the conversations as if they were not outdated.