Пример #1
0
        public void RemoteTwitchLogin(Security s, string username, ref string pCode)
        {
            if (username.ToLower().EndsWith("@beweb.co.nz"))
            {
                var remoteLogin         = "******";
                var isRemoteLoginOnline = false;

                try {
                    var twitchKey = Util.GetSetting("TwitchKey", "dsigbsd9uFSdsg897gasiu%%$#*gas79%*gakisfaf");
                    remoteLogin         = Http.Get("http://twitch.beweb.co.nz/Security/RemoteLogin?EncEmail=" + Crypto.Encrypt(username, twitchKey) + "&EncPassword="******"&EncRemembered=" + Crypto.Encrypt(Crypto.Decrypt(pCode), twitchKey));
                    isRemoteLoginOnline = true;
                } catch { }

                var localPerson  = new ActiveRecord(Security.PersonTableName, Security.PersonTableName + "ID");
                var personExists = localPerson.LoadData(new Sql("where Email = ", username.SqlizeText()));

                // If twitch is online and rejects the user login, then setup to fail the login
                if (isRemoteLoginOnline && remoteLogin == "Failed")
                {
                    pCode           = "invalid user " + Crypto.Random();
                    s.ResultMessage = "Invalid Twitch login";

                    if (personExists)
                    {
                        localPerson["IsActive"].ValueObject = false;
                        localPerson.Save();
                    }
                }

                if (remoteLogin != "Failed")
                {
                    if (!personExists)
                    {
                        localPerson["FirstName"].ValueObject = remoteLogin.Split("|")[0];
                        localPerson["LastName"].ValueObject  = remoteLogin.Split("|")[1] + "*";
                        localPerson["Email"].ValueObject     = username;
                        localPerson["Role"].ValueObject      = "administrators,superadmins,developers";
                        localPerson["Password"].ValueObject  = Security.CreateSecuredPassword(RandomPassword.Generate(5, 7));
                        localPerson["IsActive"].ValueObject  = true;
                        localPerson.Save();

                        s.ResultMessage = "Logged in via Twitch";
                    }
                    else
                    {
                        // log user in with existing account
                        localPerson["IsActive"].ValueObject = true;
                        localPerson.Save();
                        s.ResultMessage = "Logged in via Twitch, using local person";
                    }

                    pCode = Security.DecryptPassword(localPerson["Password"].ToString());
                }
            }
        }
Пример #2
0
                //public class GalleryCategoryYearsViewModel {
                //	public Page ContentPage;
                //}

        //public ActionResult GalleryCategoryYears(Page contentPage) {
        //	var model = new GalleryCategoryYearsViewModel();
        //	model.ContentPage = contentPage;
        //	return View(model);
        //}
#endif

        public ActionResult TrackingGif(string guid)
        {
            var sql    = new Sql("select * from MailLog where TrackingGuid = ", guid.SqlizeText());
            var record = new ActiveRecord("MailLog", "MailLogID");

            if (record.LoadData(sql))
            {
                record["DateViewTracked"].ValueObject = DateTime.Now;
                record.Save();
            }
            var str   = "R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
            var bytes = Convert.FromBase64String(str);

            Response.Clear();
            Response.ContentType = "image/gif";
            Response.BinaryWrite(bytes);
            return(null);
        }
Пример #3
0
        public ActionResult Index(
            string tn              //tablename		 encrypted
            , string rid           //record id		 encrypted
            , string cn            //col name		 encrypted
            , string vl            //value					un-encrypted value
            )
        {
            var tablename = Crypto.Decrypt(tn);          //tablename
            var recordid  = Crypto.DecryptID(rid);       //record id
            var colname   = Crypto.Decrypt(cn);          //col name
            var value     = vl;

            var data = new ActiveRecord(tablename, tablename + "ID");

            data.LoadData(new Sql("select * from ", tablename.SqlizeName(), " where " + tablename + "id=", recordid, ""));
            if (data != null)                                                                   //rec exists
            {
                var          field = data.GetFieldByName(colname);
                SqlizedValue dbvalue;
                if (field.ColumnType.Equals("int", StringComparison.CurrentCultureIgnoreCase))
                {
                    dbvalue = value.ToIntOrDie();
                }
                else if (field.ColumnType.Equals("nvarchar", StringComparison.CurrentCultureIgnoreCase))
                {
                    dbvalue = value.SqlizeText();
                }
                else if (field.ColumnType.Equals("datetime", StringComparison.CurrentCultureIgnoreCase))
                {
                    dbvalue = value.SqlizeDate();
                }
                else
                {
                    dbvalue = value.SqlizeText();                     //not allowed, unrecognised type?
                }
                (new Sql("update ", tablename.SqlizeName(), "set ", colname.SqlizeName(), "=", dbvalue, " where " + tablename + "id=", recordid, "")).Execute();
            }
            return(Content("OK"));
        }