Exemplo n.º 1
0
        /// <summary>Checks the logon cookie. If by using the logon cookie's packaged details we manage to log in, redirects back to default.</summary>
        protected void LogonCheck()
        {
            HttpCookie UMSWebCreds = Request.Cookies.Get("UMSWEBCREDS");

            if (UMSWebCreds != null)
            {
                if (UMSWebCreds.Value == ":")
                {
                    return;
                }
                String ID  = UMSWebCreds.Value.Split(':')[0];
                String PIN = UMSWebCreds.Value.Split(':')[1];

                //Check ID
                if (ID == null || ID.Length < 5)
                {
                    NotificationSub(Color.Pink, "Invalid ID"); Response.Cookies.Remove("UMSWEBCREDS"); return;
                }

                //Check Pin
                if (PIN == null || PIN.Length < 4)
                {
                    NotificationSub(Color.Pink, "Invalid PIN"); Response.Cookies.Remove("UMSWEBCREDS"); return;
                }

                //Setup Login Result
                string LoginResult;

                //Try to login, and if there's any exception, halt the process.
                try { LoginResult = CoreCommands.CheckUser(ID, PIN); }
                catch (Exception E) { NotificationSub(Color.Pink, E.Message); Response.Cookies.Remove("UMSWEBCREDS"); return; }

                //If it's 3, that means we logged in.
                if (LoginResult == "3")
                {
                    Response.Redirect("~/Default"); return;
                }

                NotificationSub(Color.Pink, "Username or Password Incorrect");
                Response.Cookies.Remove("UMSWEBCREDS");
            }
        }