Example #1
0
    public string login(SN.RequestInfo request)
    {
        string username = request.msg[0];
        string password = request.msg[1];

        if (SN.Sessions.Current[request.sid].ContainsKey("user"))
        {
            return("You are already logged in.");
        }
        if (username != null && password != null)
        {
            try
            {
                if (utility.database.Query("select password from Users where username = '******';")[0]["password"] == password)
                {
                    SN.Sessions.Current[request.sid]["user"] = new user {
                        username = username, password = password, session_id = request.sid
                    };
                    return("ok");
                }
                else
                {
                    return("Wrong password.");
                }
            }
            catch
            {
                return("Wrong username");
            }
        }
        else
        {
            return("Invalid data.");
        }
    }
Example #2
0
 public string lout(SN.RequestInfo request)
 {
     if (SN.Sessions.Current[request.sid].ContainsKey("user"))
     {
         SN.Sessions.Current[request.sid]["user"] = null;
     }
     return("ok");
 }
Example #3
0
    public dynamic qr(SN.RequestInfo request)
    {
        if (!SN.Sessions.Current[request.sid].ContainsKey("user"))
        {
            return("you have to be logged in");
        }

        return(utility.database.Query(request.msg));
    }
Example #4
0
 public string ping(SN.RequestInfo request)
 {
     return("");
 }