Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. $.ajax({type:"POST",data:JSON.stringify({ "username": "username","password":"password"}),url:"http://localhost/login"}).done(function(data) {
  2. alert( data );
  3. }).fail(function(data) {
  4. console.log("fail");
  5. console.log(data);
  6. });
  7.  
  8. router.post('/login', passport.authenticate('local'),function(req,res){
  9. res.send("success");
  10. });
  11.  
  12. passport.use(new LocalStrategy(
  13. {passReqToCallback: true},
  14. function(req,username, password, done) {
  15. //console.log(req);
  16. if(username=="adisak"){
  17. return done(null,{adisak:"hi"});
  18. }
  19. return done(null,false);
  20.  
  21. }
  22. ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement