Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
gamer-1478 committed Jun 6, 2022
1 parent ab356de commit 55a26e6
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 263 deletions.
60 changes: 43 additions & 17 deletions Routers/callback.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
const express = require('express');
const router = express.Router();
const { Client } = require("@notionhq/client");
const nodemailer = require('nodemailer');
const { v4: uuidv4 } = require('uuid');
const fs = require('fs');
const path = require('path');
const ejs = require("ejs");
const bcrypt = require('bcrypt');
const saltRounds = 10;

router.get('/:id', (req,res)=>{
var token = req.params.id;

const notion = new Client({
auth: process.env.NOTION_TOKEN,
})
const databaseId = process.env.NOTION_DATABASE_ID

router.get('/:id', async (req, res) => {
var token = req.params.id;
var rawdata = fs.readFileSync(path.resolve('./forgot.json'));
var forgot = JSON.parse(rawdata)
var user = forgot.forgots.find(user => user.id === token);
if(user === undefined){
return res.send({status: false, msg: "Invalid token!"})
if (user === undefined) {
return res.send({ status: false, msg: "Invalid token!" })
}
res.render('forgot', {token: token})
})
var user_no = await getUserFromEmail(user.email);
if (user_no === undefined) {
return res.send({ status: false, msg: "User not found!" })
}
res.render('forgot', { token: token, name: user_no.properties.Name.title[0].plain_text })
});

router.post('/:id', async (req,res)=>{
var passwd = req.body.password;
router.post('/:id', async (req, res) => {
var passwd = req.body.passwd;
var token = req.params.id;
var rawdata = fs.readFileSync(path.resolve('./forgot.json'));
var forgot = JSON.parse(rawdata)
var user = forgot.forgots.find(user => user.id === token);
if(user === undefined){
return res.send({status: false, msg: "Invalid token!"})
if (user === undefined) {
return res.send({ status: false, msg: "Invalid token!" })
}
var user_no = await getUserFromEmail(user.email);
if(user_no === undefined){
return res.send({status: false, msg: "User not found!"})
if (user_no === undefined) {
return res.send({ status: false, msg: "User not found!" })
}
res.render('forgotem', { token: token, name: user_no.properties.Name.title[0].plain_text })
});
await updatePassword(user_no, passwd);
res.send({ status: true, msg: "Password updated!" })
})

const getUserFromEmail = async (email) => {
//check if email in notion
Expand All @@ -55,5 +64,22 @@ const getUserFromEmail = async (email) => {
return response.results[0];
}

const updatePassword = async (user, password) => {
console.log(password, saltRounds);
return await notion.pages.update({
page_id: user.id,
properties: {
"Password": {
rich_text: [
{
text: {
content: (await bcrypt.hash(password, saltRounds)).toString()
}
}
]
}
}
})
}

module.exports = router;
40 changes: 6 additions & 34 deletions forgot.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,16 @@
{
"forgots": [
{
"id": "3a79d2f9-6336-4de4-b677-5035b890cdda",
"email": "test"
"id": "c6cf63eb-eeee-437d-aa8d-d087b08ade69",
"email": "[email protected]"
},
{
"id": "0572b68d-9559-4f7a-90a1-f8a007007156",
"email": "test"
"id": "6388c17a-b60d-4433-b5dd-73f7093c4130",
"email": "[email protected]"
},
{
"id": "dec53730-e7af-45ae-94e7-e5ad6692eaa0",
"email": "test"
},
{
"id": "2977a20e-14d0-4099-84c8-4d9c1503757b",
"email": "[email protected]"
},
{
"id": "a4ebc636-b3e0-45c2-a85d-6ecc219a1d1a",
"email": "[email protected]"
},
{
"id": "db30961b-3b5f-4dd0-8a90-c8eb75e341d2",
"email": "[email protected]"
},
{
"id": "a0cf8fe2-62dc-4ad2-9b3f-8c18d2006820",
"email": "[email protected]"
},
{
"id": "d7c97826-705d-47f3-a763-9c63ae6390e8",
"email": "[email protected]"
},
{
"id": "7f013528-58e1-4c1e-8ead-082ecb0704c2",
"email": "[email protected]"
},
{
"id": "7066c594-9a72-4980-8479-051764262ee2",
"email": "[email protected]"
"id": "576f727a-d942-4245-9d6d-d3d186a8ba91",
"email": "[email protected]"
}
]
}
120 changes: 120 additions & 0 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,52 @@ body {
justify-content: center;
}

.reg-form-div-container {
display: flex;
width: 80vw;
justify-content: space-between;
font-family: 'Outfit', sans-serif;
}

.reg-form-div {
display: flex;
flex-direction: column;
margin-bottom: 1vw;
width: 40vw;
}

.pip {
width: 40vw;
color: #16e16e;
font-size: 1.5rem;
font-family: 'Outfit', sans-serif;
}

input {
height: 40px;
width: 30vw;
border-radius: 7px;
padding: 1.3vw;
background-color: #000;
border: #2C2A2A solid 2px;
font-size: 1rem;
color: #fff;
font-family: 'Outfit', sans-serif;
}

.thank-you-p input {
height: 40px;
width: 30vw;
border-radius: 7px;
padding: 1.3vw;
background-color: #000;
border: #2C2A2A solid 2px;
font-size: 1rem;
color: #fff;
font-family: 'Outfit', sans-serif;
}


@media screen and (max-width: 1000px) {
.title {
font-size: 8rem;
Expand All @@ -56,4 +102,78 @@ body {
.thank-you-p {
font-size: 3rem;
}
}

.inpt-sub-div-1 {
width: 60vw;
display: flex;
justify-content: flex-end;
}

.inpt-sub-div {
width: 80vw;
display: flex;
justify-content: flex-end;
}

.inpt-sub {
margin-top: 15px;
width: 18vw !important;
padding-top: 0.8vw;
padding-bottom: 0.8vw;
background-color: #16e16e;
font-size: 1.5rem;
border-radius: 9px;
font-family: 'Outfit', sans-serif;
cursor: pointer;
font-weight: 400;
}


@media screen and (max-width: 1020px) {
.event-but {
width: 80vw;
font-size: 3rem;
}

.title {
font-size: 8rem;
}

.nav img {
width: 100px;
}

.reg-form p {
font-size: 3rem;
margin: 0;
margin-bottom: 5px;
width: 90vw;
}

.reg-form-div-container {
flex-direction: column;
}

.reg-form input {
width: 80vw;
height: 120px;
font-size: 3rem;
}

.inpt-sub {
width: 80vw !important;
height: 100px;
font-size: 3rem;
}

.inpt-sub-div,
.inpt-sub-div-1 {
width: 80vw;
margin-bottom: 50px;
}

.reg-form-div {
margin-bottom: 5vw;
}
}
Loading

0 comments on commit 55a26e6

Please sign in to comment.