protected void Page_Load(object sender, EventArgs e) { POCOS.AppUser o = POCOS.AppUser.Single("Select * from AppUsers where ID=@0", Common.UserID); aboutu.Value = o.About; email.Value = o.Email; first_name.Value = o.FirstName; username1.Value = o.Name; location.Value = o.Location; website.Value = o.Website; uploadedUserImage.Src = Common.UploadedImageRelPath + o.Avatar + "?width=170"; usernameview.InnerHtml = Common.Domain + "users/" + o.Name; Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); }
public void ProcessRequest(HttpContext context) { string name = context.Request.Params["name"]; POCOS.AppUser obj = POCOS.AppUser.Single(string.Format("Select * from AppUsers WHERE Name='{0}'", name)); Common.UpdateCookie(Common.InfoCookie, JObject.FromObject(new { vuID = obj.ID, vuemail = obj.Email, vuname = obj.Name, vuavatar = Common.UploadedImageRelPath + obj.Avatar })); context.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); context.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.Response.Cache.SetNoStore(); context.Response.WriteFile("LoggedIn.html"); }
private void fbLogin(HttpContext context) { string token = context.Request.Params["token"]; Facebook.FacebookClient client = new Facebook.FacebookClient(token); //client.Post() client.UseFacebookBeta = client.IsSecureConnection = true; Facebook.JsonObject o = (Facebook.JsonObject)client.Get("/me"); var db = new PetaPoco.Database(Common.HairStyleConnectionString, "System.Data.SqlClient"); using (var scope = db.GetTransaction()) { try { string first_name = (string)o["first_name"]; string name = (string)o["name"]; decimal id = Convert.ToDecimal(o["id"]); POCOS.Facebook fb = new POCOS.Facebook(); fb.name = name; fb.first_name = first_name; fb.gender = (string)o["gender"]; fb.id = id; fb.last_name = (string)o["last_name"]; fb.link = (string)o["link"]; fb.locale = (string)o["locale"]; fb.timezone = Convert.ToDouble(o["timezone"]); string updatedtime = (string)o["updated_time"]; DateTime dt; if (DateTime.TryParse(updatedtime, out dt)) fb.updated_time = dt; if (db.Exists<POCOS.Facebook>(id)) db.Update(fb); else db.Insert(fb); POCOS.AppUser au = POCOS.AppUser.FirstOrDefault("Select top 1 * from AppUsers where facebookid=@0", id); if (au == null) { au = new POCOS.AppUser(); au.FirstName = first_name; au.facebookid = id; db.Insert(au); } scope.Complete(); CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = au.ID }), Common.DefaultPassword), false); CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new { email = au.Email, name = au.Name, avatar = string.IsNullOrWhiteSpace(au.Avatar) ? null : Common.UploadedImageRelPath + au.Avatar }), false); } finally { scope.Dispose(); } } }