コード例 #1
0
        public bool CheckAccount(Account acc, Database db, bool checkAccInUse=true)
        {
            if (acc == null && !String.IsNullOrWhiteSpace(Query["password"]))
            {
                WriteErrorLine("Account credentials not valid");
                return false;
            }
            else if (acc == null && String.IsNullOrWhiteSpace(Query["password"]))
                return true;

            if (acc.Banned)
            {
                using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                    wtr.WriteLine("<Error>Account under maintenance</Error>");
                Context.Response.Close();
                return false;
            }
            if (checkAccInUse)
            {
                int? timeout = 0;
                if (db.CheckAccountInUse(acc, ref timeout))
                {
                    if (timeout != null)
                        using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                            wtr.WriteLine("<Error>Account in use. (" + timeout + " seconds until timeout.)</Error>");
                    else
                        using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                            wtr.WriteLine("<Error>Account in use.</Error>");

                    Context.Response.Close();
                    return false;
                }
            }
            return true;
        }