Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. app.post('/loginol', function(req, res, next) {
  2. passport.authenticate('local-login', function(error, user, info) {
  3. if(error) {
  4. return res.status(500).json(error);
  5. }
  6. if(!user) {
  7. console.log("user bulunamadi");
  8. return res.json("bulunamadi");
  9. }
  10. var data=[];
  11. data.push(user);
  12.  
  13. res.json(data);
  14. console.log("user"+user);
  15.  
  16. })(req, res, next);
  17. });
  18.  
  19. <script type="text/javascript">
  20. $(document).ready(function(){
  21. $("#loginol").click(function(){
  22. console.log("loginol");
  23.  
  24. var username = $("#username").val();
  25. var password = $("#password1").val();
  26. console.log("username"+username);
  27. console.log("password"+password);
  28. data={};
  29. data.username=username;
  30. data.password=password;
  31. $.ajax({
  32. type: "POST",
  33. url: '/loginol',
  34. data: data,
  35. success: function(data) {
  36. if(data !="bulunamadi"){
  37.  
  38. document.getElementById("loginkismi").style.visibility = "hidden";
  39. $("#kullanicikismi").append("<li>"+data+"</li>")
  40. document.getElementById("kullanicikismi").style.visibility = "visible";
  41. }
  42. }
  43. });
  44. });
  45. });
  46. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement