Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1.  
  2. There are two issues I am seeing working on section 31: Authentication Lecture 240....
  3. 1. Login form redirects to itself even a good user account and password is used.
  4. 2. URL of the login page shows name value pairs-- eg ?username=alex&password=something
  5. which i am assuming is not good for any site.
  6. ++++++++++++++++++++++++++
  7. app.JS code
  8. +++++++++++++++++++++++++
  9. passport.use(new localStrategy(User.authenticate()));
  10. passport.serializeUser(User.serializeUser());
  11. passport.deserializeUser(User.deserializeUser());
  12.  
  13.  
  14. // More code and other routes here.
  15.  
  16. // LOGIN ROUTES
  17. // Render login form
  18. app.get("/login", function(req, res) {
  19. res.render("login");
  20. });
  21.  
  22. // LOGIN LOGIC
  23. app.post("/login", passport.authenticate("local", {
  24. successRedirect: "/secret",
  25. failureRedirect: "/login"
  26. }) , function(req, res) {
  27.  
  28. });
  29.  
  30.  
  31.  
  32. +++++++++++++++++++++++
  33. login.ejs
  34. +++++++++++++++++++++++
  35.  
  36. <h1>LOGIN</h1>
  37.  
  38. <form action="/login" method "POST">
  39. <input type="text" name="username" placeholder="username">
  40. <input type="password" name="password" placeholder="password">
  41. <button>Login</button>
  42. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement