mirror of
https://gitlab.com/nekoya/web.git
synced 2024-11-14 02:16:19 +01:00
Merge branch 'main' of https://gitlab.com/nekoya/web
This commit is contained in:
commit
a5022d4447
8 changed files with 294 additions and 241 deletions
|
@ -41,6 +41,18 @@
|
|||
border-color: red;
|
||||
}
|
||||
|
||||
.button-close {
|
||||
color: white;
|
||||
background-color: darkred;
|
||||
border-color: darkred;
|
||||
border-radius: 100px;
|
||||
}
|
||||
|
||||
.button-close:hover {
|
||||
background-color: red;
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
.button-checkout_1 {
|
||||
color: white;
|
||||
background-color: darkred;
|
||||
|
|
124
public/css/register-error.css
Normal file
124
public/css/register-error.css
Normal file
|
@ -0,0 +1,124 @@
|
|||
body {
|
||||
font-family: 'Poppins', sans-serif;
|
||||
background-color: #1b1c1e;
|
||||
}
|
||||
|
||||
.nav-color {
|
||||
background-color: #212226;
|
||||
}
|
||||
|
||||
.nav-radius {
|
||||
border-bottom-left-radius: 20px;
|
||||
border-bottom-right-radius: 20px;
|
||||
}
|
||||
|
||||
.card {
|
||||
position: center;
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
border-radius: 20px;
|
||||
background-color: #212226;
|
||||
}
|
||||
|
||||
.icon {
|
||||
position: center;
|
||||
margin: auto;
|
||||
width: 70%;
|
||||
height: 70%;
|
||||
}
|
||||
|
||||
.btn {
|
||||
background-color: darkred;
|
||||
border-color: darkred;
|
||||
border-radius: 100px;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background-color: red;
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 766px) {
|
||||
.card h2 {
|
||||
font-size: 7vw;
|
||||
}
|
||||
|
||||
.card h5 {
|
||||
font-size: 5vw;
|
||||
}
|
||||
|
||||
.card a {
|
||||
font-size: 5vw;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
width: 11vw;
|
||||
height: 11vw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media screen and (min-width: 767px) {
|
||||
.card h2 {
|
||||
font-size: 4vw;
|
||||
}
|
||||
|
||||
.card h5 {
|
||||
font-size: 2vw;
|
||||
}
|
||||
|
||||
.card a {
|
||||
font-size: 2.5vw;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
width: 8vw;
|
||||
height: 8vw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media screen and (min-width: 993px) {
|
||||
.card h2 {
|
||||
font-size: 3vw;
|
||||
}
|
||||
|
||||
.card h5 {
|
||||
font-size: 1.3vw;
|
||||
}
|
||||
|
||||
.card a {
|
||||
font-size: 1.5vw;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
width: 6vw;
|
||||
height: 6vw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1400px) {
|
||||
.card h2 {
|
||||
font-size: 3vw;
|
||||
}
|
||||
|
||||
.card h5 {
|
||||
font-size: 1.5vw;
|
||||
}
|
||||
|
||||
.card a {
|
||||
font-size: 2vw;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
width: 6vw;
|
||||
height: 6vw;
|
||||
}
|
||||
|
||||
:focus {
|
||||
outline: 0 !important;
|
||||
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0) !important;
|
||||
}
|
||||
}
|
339
routes/api.js
339
routes/api.js
|
@ -1,12 +1,9 @@
|
|||
const express = require("express");
|
||||
const bcrypt = require("bcrypt");
|
||||
const randtoken = require("rand-token");
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const db = require("../modules/db");
|
||||
const mail = require("../modules/mail");
|
||||
const auth = require("../auth/auth");
|
||||
|
||||
const saltRounds = 10;
|
||||
|
||||
|
@ -241,61 +238,53 @@ router.post("/login", async (req, res) => {
|
|||
}
|
||||
});
|
||||
|
||||
router.post("/verify-mail", async (req, res) => {
|
||||
if (!req.body.token) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
} else {
|
||||
const conn = db.connect();
|
||||
conn.query(
|
||||
'SELECT * FROM users WHERE token ="' + req.body.token + '"',
|
||||
function (err, result) {
|
||||
if (err) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
}
|
||||
if (result.length > 0) {
|
||||
if (result[0].verify == 0) {
|
||||
var data = {
|
||||
verify: 1,
|
||||
token: randtoken.generate(64),
|
||||
};
|
||||
conn.query(
|
||||
'UPDATE users SET ? WHERE email ="' + result[0].email + '"',
|
||||
data,
|
||||
function (err, result) {
|
||||
if (err) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
} else {
|
||||
res.status(200);
|
||||
res.json({
|
||||
message: "Verified ~",
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
res.status(403);
|
||||
res.json({
|
||||
message: "Forbidden",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
}
|
||||
router.get("/verify-mail", async (req, res) => {
|
||||
const conn = db.connect();
|
||||
conn.query(
|
||||
'SELECT * FROM users WHERE token ="' + req.query.token + '"',
|
||||
function (err, result) {
|
||||
if (err) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
}
|
||||
if (result.length > 0) {
|
||||
if (result[0].verify == 0) {
|
||||
var data = {
|
||||
verify: 1,
|
||||
};
|
||||
db_connect.query(
|
||||
'UPDATE users SET ? WHERE email ="' + result[0].email + '"',
|
||||
data,
|
||||
function (err, result) {
|
||||
if (err) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
} else {
|
||||
res.status(200);
|
||||
res.json({
|
||||
message: "Verified ~",
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
res.status(403);
|
||||
res.json({
|
||||
message: "Forbidden",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
router.post("/request-reset-password", async (req, res) => {
|
||||
|
@ -411,193 +400,71 @@ router.post("/reset-password", async (req, res) => {
|
|||
});
|
||||
|
||||
router.post("/checkout", async (req, res) => {
|
||||
if (!req.query.key) {
|
||||
res.status(401);
|
||||
res.json({
|
||||
message: "Unauthorized",
|
||||
});
|
||||
} else {
|
||||
auth.auth_checker(req.query.key).then((status) => {
|
||||
if (status) {
|
||||
if (
|
||||
!req.body.firstName ||
|
||||
!req.body.lastName ||
|
||||
!req.body.phoneNumber ||
|
||||
!req.body.streetAddress1 ||
|
||||
!req.body.streetAddress2 ||
|
||||
!req.body.region ||
|
||||
!req.body.province ||
|
||||
!req.body.city ||
|
||||
!req.body.district ||
|
||||
!req.body.subDistrict ||
|
||||
!req.body.postalCode ||
|
||||
!req.body.logistic ||
|
||||
!req.body.data
|
||||
) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
} else {
|
||||
const conn = db.connect();
|
||||
conn.query(
|
||||
"SELECT * FROM users WHERE token = ?",
|
||||
[req.query.key],
|
||||
async function (error, resp, fields) {
|
||||
if (error) {
|
||||
res.status(401);
|
||||
res.json({
|
||||
message: "Unauthorized",
|
||||
});
|
||||
} else {
|
||||
var data = {
|
||||
firstName: req.body.firstName,
|
||||
lastName: req.body.lastName,
|
||||
phoneNumber: req.body.phoneNumber,
|
||||
streetAddress1: req.body.streetAddress1,
|
||||
streetAddress2: req.body.streetAddress2,
|
||||
region: req.body.region,
|
||||
province: req.body.province,
|
||||
city: req.body.city,
|
||||
district: req.body.district,
|
||||
subDistrict: req.body.subDistrict,
|
||||
postalCode: req.body.postalCode,
|
||||
logistic: req.body.logistic,
|
||||
paymentMethod: '-',
|
||||
data: req.body.data,
|
||||
userId: resp[0].id,
|
||||
paid: '0',
|
||||
status: 'pending'
|
||||
};
|
||||
conn.query(
|
||||
"INSERT INTO transactions SET ?",
|
||||
data,
|
||||
function (error, response, fields) {
|
||||
if (error) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
} else {
|
||||
conn.query(
|
||||
'SELECT * FROM transactions WHERE id ="' + response.insertId + '"',
|
||||
function (err, result) {
|
||||
if (err) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
} else {
|
||||
res.status(201);
|
||||
res.json({
|
||||
'order_id': result[0].id,
|
||||
'data': result[0].data
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
} else {
|
||||
res.status(401);
|
||||
res.json({
|
||||
message: "Unauthorized",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.post("/transaction", async (req, res) => {
|
||||
if (!req.query.key) {
|
||||
res.status(401);
|
||||
res.json({
|
||||
message: "Unauthorized",
|
||||
});
|
||||
} else {
|
||||
auth.auth_checker(req.query.key).then((status) => {
|
||||
if (status) {
|
||||
const conn = db.connect();
|
||||
conn.query(
|
||||
"SELECT * FROM users WHERE token = ?",
|
||||
[req.query.key],
|
||||
async function (error, response, fields) {
|
||||
if (error) {
|
||||
res.status(401);
|
||||
res.json({
|
||||
message: "Unauthorized",
|
||||
});
|
||||
} else {
|
||||
conn.query(
|
||||
"SELECT * FROM transactions WHERE userId = ?",
|
||||
[response[0].id],
|
||||
async function (error, resp, fields) {
|
||||
if (error) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
} else {
|
||||
res.status(200);
|
||||
res.json(resp);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
res.status(401);
|
||||
res.json({
|
||||
message: "Unauthorized",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.get("/subscribe", (req, res) => {
|
||||
if (!req.query.email) {
|
||||
if (
|
||||
!req.body.firstName ||
|
||||
!req.body.lastName ||
|
||||
!req.body.phoneNumber ||
|
||||
!req.body.streetAddress1 ||
|
||||
!req.body.streetAddress2 ||
|
||||
!req.body.region ||
|
||||
!req.body.province ||
|
||||
!req.body.city ||
|
||||
!req.body.district ||
|
||||
!req.body.subDistrict ||
|
||||
!req.body.postalCode ||
|
||||
!req.body.logistic ||
|
||||
!req.body.data
|
||||
) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
} else {
|
||||
const conn = db.connect();
|
||||
conn.execute(
|
||||
"SELECT * FROM `subscribe` WHERE `email` = ?",
|
||||
[req.query.email],
|
||||
function (err, results) {
|
||||
if (!results[0]) {
|
||||
let data = {
|
||||
email: req.query.email,
|
||||
type: "email"
|
||||
};
|
||||
conn.query(
|
||||
"INSERT INTO subscribe SET ?",
|
||||
data,
|
||||
function (err, resp) {
|
||||
if (err) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
} else {
|
||||
res.status(201);
|
||||
res.json({
|
||||
message: "Success",
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
res.status(200);
|
||||
var data = {
|
||||
firstName: req.body.firstName,
|
||||
lastName: req.body.lastName,
|
||||
phoneNumber: req.body.phoneNumber,
|
||||
streetAddress1: req.body.streetAddress1,
|
||||
streetAddress2: req.body.streetAddress2,
|
||||
region: req.body.region,
|
||||
province: req.body.province,
|
||||
city: req.body.city,
|
||||
district: req.body.district,
|
||||
subDistrict: req.body.subDistrict,
|
||||
postalCode: req.body.postalCode,
|
||||
logistic: req.body.logistic,
|
||||
paymentMethod: '-',
|
||||
data: req.body.data,
|
||||
userId: 14,
|
||||
paid: '0',
|
||||
status: 'pending'
|
||||
};
|
||||
conn.query(
|
||||
"INSERT INTO transactions SET ?",
|
||||
data,
|
||||
function (error, response, fields) {
|
||||
if (error) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Success",
|
||||
message: "Bad Request",
|
||||
});
|
||||
} else {
|
||||
conn.query(
|
||||
'SELECT * FROM transactions WHERE id ="' + response.insertId + '"',
|
||||
function (err, result) {
|
||||
if (err) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
message: "Bad Request",
|
||||
});
|
||||
} else {
|
||||
res.status(201);
|
||||
res.json({
|
||||
'order_id': result[0].id,
|
||||
'data': result[0].data
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ router.route("/register")
|
|||
if (data == 200) {
|
||||
res.render("pages/register-verification-sent");
|
||||
} else {
|
||||
res.redirect("/register");
|
||||
res.render("pages/register-error")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -566,8 +566,25 @@
|
|||
<input id="newsletter_email" type="email" placeholder="Input Your Email" required="required"
|
||||
data-error="valid email is required">
|
||||
<button id="newsletter_submit" class="newsletter_submit_btn trans_300"
|
||||
onclick="subscribe()" value="submit">Subscribe
|
||||
onclick="subscribe()" value="submit" data-toggle="modal" data-target="#exampleModal">Subscribe
|
||||
</button>
|
||||
<div class="modal fade black" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content" style="background-color: #1b1c1e; color: white;">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" style="text-align: center;">
|
||||
You have successfully subscribed to the newsletter. Thank you for your subscription.
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -44,10 +44,10 @@
|
|||
</button>
|
||||
</div>
|
||||
<div class="modal-body" style="text-align: center;">
|
||||
Succefully added to Bag
|
||||
Successfully added to Bag
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-secondary button-close" data-dismiss="modal">Close</button>
|
||||
<a href="/bag"><button type="button" class="btn button-bag">Bag</button></a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
33
views/pages/register-error.ejs
Normal file
33
views/pages/register-error.ejs
Normal file
|
@ -0,0 +1,33 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<%- include('../layouts/header.ejs', {title: 'Register', state: 'register-error'}); %>
|
||||
|
||||
<body>
|
||||
<%- include('../layouts/navbar.ejs', {types: 'v2', title: 'Register'}); %>
|
||||
<br>
|
||||
|
||||
|
||||
<div data-aos="fade-in" data-aos-delay="500" class="container">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="card col-md-6 col-lg-6 col-xl-8">
|
||||
<div class="card-header" style="color: cyan;">
|
||||
<h2>ERROR</h2>
|
||||
</div>
|
||||
<lottie-player style="display: -webkit-box;-webkit-box-pack: center;" autoplay background="transparent" class="icon" loop speed="1"
|
||||
src="https://assets5.lottiefiles.com/temp/lf20_QYm9j9.json"></lottie-player>
|
||||
<div class="card-body">
|
||||
<h5 class="card-text" style="color: cyan;">An error has occured... Make sure to check if you have empty fields, or if your email has been registered before. Click the button below to get back to the register page.</h5>
|
||||
<br style="display: block;content: ' ';margin: 1vw 0;line-height: 1vw;">
|
||||
<a class="btn btn-primary" href="register">Register</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%- include('../layouts/footer.ejs', {state: 'register-error'}); %>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue