Advertisement
Guest User

Untitled

a guest
Jan 27th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. function getResponse(_url) {
  2. http.get(_url, function(res) {
  3. return res;
  4. }).on('error', function(e) {
  5. log("AUTH ERROR! Reason: "+e);
  6. });
  7. }
  8. function checkAuth(login, password) {
  9. var response = getResponse("somehost.ru", "/updater/auth.php?login="+login+"&pass="+password);
  10.  
  11. if(response == "Success") {
  12. return [true, login, "user", ""];
  13. } else {
  14. return [false, login, "user", response];
  15. }
  16. }
  17. //часть из кода авторизации
  18. case "auth":
  19. localUserInfo = checkAuth(cmdArr[1], cmdArr[2]);
  20. if(localUserInfo[0]) {
  21. userAuthed = localUserInfo[0];
  22. userName = localUserInfo[1];
  23. userGroup = localUserInfo[2];
  24. connection.send("succauth "+userName);
  25. log("User with ID: "+index+" successfully logged in! Login: "+userName);
  26. } else {
  27. log("User with ID: "+index+" failed to auth properly. Disconnecting..");
  28. connection.send("err autherr");
  29. connection.send("err "+localUserInfo[3]);
  30. connection.close();
  31. }
  32.  
  33. //Выхлоп с консоли клиента:
  34. //localjs.js:34 Error: autherr
  35. //localjs.js:34 Error: undefined
  36. //localjs.js:40 Server closed connection..
  37. //undefined тут это localUserInfo[3]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement