Controller:const GetMain = (req, res) => { const userContext = new DbContext().Initialize("users") const Auth = new AuthJWT() const Parser = new FirebaseParser() let logged = Auth.IsLoggedIn(req) let data = Auth.GetUserData(req) let username = req.params.user if(logged){ if(!data.profileCreated){ res.redirect(`User/Profile/Create/${username}`) } else{ userContext .where("username") .get() .then((snapshopt) => { snapshopt.forEach((user) => { console.log(user) let profileUpdatedFirebase = user["_fieldsProto"]["profileCreated"]["booleanValue"] }) }) res.render('User/Main', data) res.end() } } else{ res.render("Auth/Login", { error: "You need an account to access user page!" }) res.end() } } Router:const express = require("express"); const UserController = require("../Controllers/UserController"); const router = express.Router(); router.get("/Main/:user", UserController.GetMain) router.get("/Profile/Create", UserController.CreateUserProfile) module.exports = router The problem is when I get in the if and get redirected I get route like this "http://localhost:3000/User/Main/User/Profile/Create/adminiki" when I should be getting only this "http://localhost:3000/User/Profile/Create/adminiki". I add the user part in the app.js file so thanks not the problem any idea how to fix this?
Submitted June 03, 2020 at 05:18PM by draganov11
No comments:
Post a Comment