mirror of
https://gitlab.com/nekoya/web.git
synced 2024-11-14 10:26:40 +01:00
Update register
This commit is contained in:
parent
b84dae8700
commit
e80a4ee9b4
2 changed files with 35 additions and 8 deletions
|
@ -22,7 +22,25 @@ function getProduct(id) {
|
|||
.catch(error => console.log(error))
|
||||
}
|
||||
|
||||
function register(email, password, first_name, last_name) {
|
||||
let params = new URLSearchParams({
|
||||
'email': email,
|
||||
'password': password,
|
||||
'first_name': first_name,
|
||||
'last_name': last_name
|
||||
})
|
||||
const conf = {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}
|
||||
return axios.post(HOST + '/register', params, conf)
|
||||
.then(response => response.status)
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getProducts,
|
||||
getProduct
|
||||
getProduct,
|
||||
register
|
||||
}
|
|
@ -2,9 +2,8 @@ const express = require('express')
|
|||
const router = express.Router()
|
||||
var registerlogin = require("./registerlogin");
|
||||
|
||||
let product_controller = require("../controllers/productController");
|
||||
let controller = require("../controllers/controllers");
|
||||
|
||||
router.post("/register", registerlogin.register);
|
||||
router.post("/login", registerlogin.login);
|
||||
router.get("/verify-email", registerlogin.verifyemail);
|
||||
|
||||
|
@ -12,6 +11,20 @@ router.get('/', (_req, res) => {
|
|||
res.render('pages/index');
|
||||
})
|
||||
|
||||
router.route('/register')
|
||||
.get((_req, res) => {
|
||||
res.render('pages/register');
|
||||
})
|
||||
.post((req, res) => {
|
||||
controller.register(req.body.email, req.body.password, req.body.first_name, req.body.last_name).then(data => {
|
||||
if (data == 200) {
|
||||
res.render("pages/register-verification-sent");
|
||||
} else {
|
||||
res.render("pages/register-error");
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
router.get('/login', (_req, res) => {
|
||||
res.render('pages/login');
|
||||
})
|
||||
|
@ -25,7 +38,7 @@ router.get('/otp', (_req, res) => {
|
|||
})
|
||||
|
||||
router.get('/products', (_req, res) => {
|
||||
product_controller.getProducts().then(data => {
|
||||
controller.getProducts().then(data => {
|
||||
res.render('pages/products', {data: data});
|
||||
})
|
||||
})
|
||||
|
@ -56,10 +69,6 @@ router.get('/payment', (_req, res) => {
|
|||
res.render('pages/payment')
|
||||
})
|
||||
|
||||
router.get('/register', (_req, res) => {
|
||||
res.render('pages/register')
|
||||
})
|
||||
|
||||
router.get('/about-us', (_req, res) => {
|
||||
res.render('pages/about-us')
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue