what im trying have log in page, sign page. login , signup work fine, perform whatever written in express using passport. want make route '/dashboard'. did , it's dashboard component made of other components navbar , body/content. how write in react router in such way allows me access route /dashboard if user authenticated. in express write function :
function isloggedin(req, res, next) { //if user authenticated in session, carry on if (req.isauthenticated()) return next(); //cuz want move on incase we're stuck here //if arent redirect them home page res.redirect('/'); } however didn't write in dashboard route in express. did in react-router. component hierarchy right now
<app/> <dashboard/> <navbar/> <navmenu/> <body/> <login/> <signup/> <about/> and routing :
<route> <route name ="signup" path="/signup" handler={signup} /> <route name ="login" path="/" handler={login} /> <route name ="app" path="/dashboard" handler={app} > <route name ="logout" path="/logout" handler={navmenu} /> </route> </route> i don't understand if i'm grasping concept right, webpage displaying doesn't seem it. @ localhost:3000/ comes log in page, , can toggle between , signup page fine, when log in button hit uses express login (it can use react-router correct?), on success goes /dashboard (res.redirect('/dashboard') in express). seems routes handled react router has single page app feel, whereas express feels i'm going new webpage (i'm guessing happens because of react-router changing url , rendering component want?). in navmenu component link logout button logout url changes localhost:3000/logout , nothing happens.
i nested under login dashboard , it's routehandler has go through login.
<login> <app> <routehandler> <dashboard../> <data../> <etc../>
Comments
Post a Comment