Example #1
0
        private static async Task <bool> LoadSession()
        {
            bool authorized = false;

            if (File.Exists(SessionPath))
            {
                BinaryFormatter bf      = new BinaryFormatter();
                FileStream      file    = File.Open(SessionPath, FileMode.Open);
                INESession      session = (INESession)bf.Deserialize(file);
                file.Close();

                authorized = await Login(session.Username, session.Password,
                                         endpoint : session.Endpoint, poolID : session.PoolID, clientID : session.ClientID);

                if (!authorized)
                {
                    File.Delete(SessionPath);
                }
            }

            if (!authorized)
            {
                Auth = null;
            }

            return(authorized);
        }
Example #2
0
        public static async Task <bool> Login(string username, string password,
                                              RegionEndpoint endpoint = null, string poolID = null, string clientID = null)
        {
            RegionEndpoint newEndpoint = DefaultEndpoint;

            if (endpoint != null)
            {
                newEndpoint = endpoint;
            }

            string newPoolID = DefaultPoolID;

            if (poolID != null)
            {
                newPoolID = poolID;
            }

            string newClientID = DefaultClientID;

            if (clientID != null)
            {
                newClientID = clientID;
            }

            Auth = new INEAuthorizor(newEndpoint, newPoolID, newClientID, username);
            bool authorized = await Auth.Login(password);

            return(authorized);
        }