Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getResponse(_url) {
- http.get(_url, function(res) {
- return res;
- }).on('error', function(e) {
- log("AUTH ERROR! Reason: "+e);
- });
- }
- function checkAuth(login, password) {
- var response = getResponse("somehost.ru", "/updater/auth.php?login="+login+"&pass="+password);
- if(response == "Success") {
- return [true, login, "user", ""];
- } else {
- return [false, login, "user", response];
- }
- }
- //часть из кода авторизации
- case "auth":
- localUserInfo = checkAuth(cmdArr[1], cmdArr[2]);
- if(localUserInfo[0]) {
- userAuthed = localUserInfo[0];
- userName = localUserInfo[1];
- userGroup = localUserInfo[2];
- connection.send("succauth "+userName);
- log("User with ID: "+index+" successfully logged in! Login: "+userName);
- } else {
- log("User with ID: "+index+" failed to auth properly. Disconnecting..");
- connection.send("err autherr");
- connection.send("err "+localUserInfo[3]);
- connection.close();
- }
- //Выхлоп с консоли клиента:
- //localjs.js:34 Error: autherr
- //localjs.js:34 Error: undefined
- //localjs.js:40 Server closed connection..
- //undefined тут это localUserInfo[3]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement