dsckgec / cleanurge-backend Goto Github PK
View Code? Open in Web Editor NEWScalable waste management IoT based application with features to autodetect and alarm authorities on overaccumulation of waste
License: GNU General Public License v3.0
Scalable waste management IoT based application with features to autodetect and alarm authorities on overaccumulation of waste
License: GNU General Public License v3.0
If you look at the reports model, we are currently storing just the address of the report as string. Recording the coordinates along with the address would add extra precision as well as minimize the chances of fake reporting.
You must have received emails asking you to verify your account after creating a new account over some platform. These emails are generally not just textual emails but have their own UI, which is actually coded using simple HTML and CSS. Example:
This is what this issue is about.
utils
directory, create a new file named email.js
. The contents of the file are given below:
const email_ui = (email, name, link) => {
const ui = `<HTML CODE GOES HERE>`
return ui;
}
module.exports = email_ui;
email
, name
and link
respectively. Do not forget to use these variables in the email's content. How the email should look is totally upto you!Please create and hand me a device ID to test the routes with the MCU.
-to the Database Administrator
There is a property named 'status' under the user model, which has a value of unverified
by default after a user registers into the application. Only those users are allowed to login, who have the status value as verified
. So, all users after registration are to be sent an email right after registration with a link which can be used to verify them.
Create a route under user.route.js
file with the following properties
api/user/verify/:token
status
of the fetched user to "verified", deletes the token from the fetched user documentAdd another property under user schema named token
with default value as null. When a user registers into the platform, assign this token a random string value of length 32 or 64. (You can use helper functions added in the utils directory for this) and add this token in the request body in the Register controller function
In the Register controller function, after receiving a response from the Register service, use nodemailer or any other library to mail the requesting user with the URL. For this step, use utils/email.js
to generate the html body of the email by passing the email, name and the link (http://cleanurge.herokuapp.com/api/user/verify/{token}
)
We need a simple webpage, something like this to provide the users the option to reset password.
/api/user/reset-password
Currently, there are endpoints to register a new account, login as well as fetch user(s). When a user is logged in to the system, there is to be an update feature wherein the authorized user can update his / her name, phone number and address.
routes/user.route.js
along with the swagger documentation for the same.controllers/user.controller.js
services/user.service.js
Make sure you follow the coding conventions used throughout the project!
Password handling is usually done in three ways
Routes, controllers and services to achieve the above:
api/user/change-password
new_password
and confirmed_password
, checks if both are the same and updates the requesting user's password.api/user/forgot-password
email
, generates a random string - reset_token
of length 32, adds this token to the user's document (add a new property under the user model to save this token) and emails the user with the link - http://cleanurge.herokuapp.com/api/user/reset-password/{reset_token}
password_ui
in the utils directory in a file with the same name, which takes in email and link as parameter and returns the HTML to be mailed as email body. YOU DO NOT NEED TO CREATE THIS FUNCTION.api/user/reset-password/:reset_token
views/reset-password.ejs
file - that you need to render. Access the reset_token from the params and pass it to the webpage while rendering as well. YOU DO NOT NEED TO CREATE THIS FILE.api/user/reset-password
reset_token
, new_password
and confirmed_password
, checks if both passwords are the same and updates the user's password which has the same reset_token as provided in the request body.The password_ui and the webpage to reset passwords will be worked on separately and are put up in different issues. While working on this issue, assume that these two are already present in the project.
See issue #2 for reference.
password_ui
We would want to update the waste threshold of each device, as the devices keep requesting to the server periodically in the GET method to /api/beacon/{id}
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.