private void SetPanelsVisibility(bool val) { if (ConfigurationManager.AppSettings["ApplicationType"].ToLower() == "yourtribute") { PanelUserName.Visible = val; UpdatePanel1.Visible = val; CityPanel.Visible = val; if (val == false) { PanelPassword.Attributes.Remove("class"); PanelPassword.CssClass = "yt-signup-Password"; PanelConfirmPassword.CssClass = "yt-signup-ConfirmPassword"; SignupNewsLetter.InnerHtml = "I would like to receive periodic newsletters from Your Tribute, including company news and special offers."; } else { PanelPassword.CssClass = "signup-Password"; PanelConfirmPassword.CssClass = "signup-Password"; SignupNewsLetter.InnerHtml = "I would like to receive periodic newsletters, including tips and tricks when creating tributes,from Your Tribute."; } } else { SignupNewsLetter.InnerHtml = "I would like to receive periodic newsletters, including tips and tricks when creating websites,from Your Moments."; } txtEmail.Focus(); lblBusinessAcctDesc.Visible = val; BusinessTypePanel.Visible = val; WebsitePanel.Visible = val; StreetAddressPanel.Visible = val; CompanyNamePanel.Visible = val; ZipCodePanel.Visible = val; PanelPhone.Visible = val; FirstNamePanel.Visible = !val; LastNamePanel.Visible = !val; lblPersonalAcctDesc.Visible = !val; txtWebsiteAddress.Text = ""; txtEmail.Text = ""; // Added For Event Handling - Parul if (Request.QueryString["EventID"] != null) { string email = Request.QueryString["Email"]; txtEmail.Text = email; } else if (Request.QueryString["TributeID"] != null) { if (Request.QueryString["Email"] != null) txtEmail.Text = Request.QueryString["Email"]; } txtUsername.Text = ""; txtPassword.Text = ""; txtConfirmPassword.Text = ""; txtBusinessName.Text = ""; txtFirstName.Text = ""; txtLastName.Text = ""; txtStreetAddress.Text = ""; txtCity.Text = ""; txtPhoneNumber1.Text = ""; txtPhoneNumber2.Text = ""; txtPhoneNumber3.Text = ""; txtZipCode.Text = ""; rfvtxtCity.Visible = val; ddlBusinessType.SelectedIndex = 0; ddlCountry.SelectedIndex = 0; this._presenter.OnStateLoad(Locationid(ddlCountry.SelectedValue)); chkAgreeTermsUse.Checked = false; if (FacebookWebContext.Current.Session != null) { //Display user data captured from the Facebook API. try { var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken); var me = (IDictionary<string, object>)fbwc.Get("me"); string fql = "Select current_location, email from user where uid = " + (string)me["id"]; JsonArray me2 = (JsonArray)fbwc.Query(fql); var mm = (IDictionary<string, object>)me2[0]; txtFirstName.Text = (string)me["first_name"]; txtLastName.Text = (string)me["last_name"]; JsonObject hl = (JsonObject)mm["current_location"]; if ((string)hl[0] != null) { txtCity.Text = (string)hl[0]; setLocationFromFacebookLocation(ddlCountry, (string)hl[2]); this._presenter.OnStateLoad(Locationid(ddlCountry.SelectedValue)); setLocationFromFacebookLocation(ddlStateProvince, (string)hl[1]); } string email_ = string.Empty; // user.proxied_email; string result = (string)mm["email"]; if (!string.IsNullOrEmpty(result)) { email_ = result; } txtEmail.Text = email_; } catch (Exception ex) { if (!PortalValidationSummary.Visible) { string msg = "Problems with Facebook session. Please <a href=\"#\" onclick=\"fb_logout(); return false;\">" + " <img id=\"fb_logout_image\" src=\"http://static.ak.fbcdn.net/images/fbconnect/logout-buttons/logout_small.gif\" alt=\"Connect\"/>" + "</a> and try again." + ex; lblErrMsg.InnerHtml = ShowMessage(headertext, msg, 0); lblErrMsg.Visible = true; } } } }
protected void doFacebookSignup() { var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken); var me = (IDictionary<string, object>)fbwc.Get("me"); string fbName = (string)me["first_name"] + " " + (string)me["last_name"]; string UserName = fbName.ToLower().Replace(" ", "_").Replace("'", "");/*+ "_"+_FacebookUid.ToString()*/ string fql = "Select current_location,pic_square,email from user where uid = " + (string)me["id"]; JsonArray me2 = (JsonArray)fbwc.Query(fql); var mm = (IDictionary<string, object>)me2[0]; Nullable<int> state = null; Nullable<int> country = null; string _UserImage = "images/bg_ProfilePhoto.gif"; if (!string.IsNullOrEmpty((string)mm["pic_square"])) { _UserImage = (string)mm["pic_square"]; // get user image } string city = ""; JsonObject hl = (JsonObject)mm["current_location"]; if ((string)hl[0] != null) { city = (string)hl[0]; UserManager usrmngr = new UserManager(); object[] param = { (string)hl[2],(string)hl[1] }; if (usrmngr.GetstateIdByName(param) > 0) { state = usrmngr.GetstateIdByName(param); } if (usrmngr.GetCountryIdByName((string)hl[2]) > 0) { country = usrmngr.GetCountryIdByName((string)hl[2]); } } string password_ = string.Empty; string email_ = string.Empty; //user.proxied_email; string result = (string)mm["email"]; if (!string.IsNullOrEmpty(result)) { email_ = result; password_ = RandomPassword.Generate(8, 10); password_ = TributePortalSecurity.Security.EncryptSymmetric(password_); } UserRegistration objUserReg = new UserRegistration(); TributesPortal.BusinessEntities.Users objUsers = new TributesPortal.BusinessEntities.Users( UserName, password_, (string)me["first_name"], (string)me["last_name"], email_, "", false, city, state, country, 1, _FacebookUid); objUsers.UserImage = _UserImage; objUserReg.Users = objUsers; /*System.Decimal identity = (System.Decimal)*/ UserInfoManager umgr = new UserInfoManager(); umgr.SavePersonalAccount(objUserReg); if (objUserReg.CustomError != null) { messageText.Text=string.Format("<h2>Sorry, {0}.</h2>" + "<h3>Those Facebook credentials are already used in some other Your Tribute Account</h3>", fbName); } else { SessionValue _objSessionValue = new SessionValue(objUserReg.Users.UserId, objUserReg.Users.UserName, objUserReg.Users.FirstName, objUserReg.Users.LastName, objUserReg.Users.Email, objUserReg.UserBusiness == null ? 1 : 2, "Basic", objUserReg.Users.IsUsernameVisiable); TributesPortal.Utilities.StateManager stateManager = TributesPortal.Utilities.StateManager.Instance; stateManager.Add("objSessionvalue", _objSessionValue, TributesPortal.Utilities.StateManager.State.Session); SaveSessionInDB(); Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", Session.SessionID)); Response.Cookies["ASP.NET_SessionId"].Domain = "." + WebConfig.TopLevelDomain; showDialog.Text = "false"; refreshPage.Text = "true"; } }
private UserRegistration SaveAccount() { int usertype = 1; if (rdoBusinessAccount.Checked) usertype = 2; UserRegistration objUserReg = new UserRegistration(); int state = -1; if (ddlStateProvince.SelectedValue != "") { state = int.Parse(ddlStateProvince.SelectedValue); } string _Pass = TributePortalSecurity.Security.EncryptSymmetric(txtPassword.Text.ToLower()); string _UserImage = "images/bg_ProfilePhoto.gif"; Nullable<Int64> facebookUid = null; var fbWebContext = FacebookWebContext.Current; if (FacebookWebContext.Current.Session != null) { facebookUid = fbWebContext.UserId; try { var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken); string fql = "Select pic_square from user where uid = " + fbWebContext.UserId; JsonArray me2 = (JsonArray)fbwc.Query(fql); var mm = (IDictionary<string, object>)me2[0]; if (!string.IsNullOrEmpty((string)mm["pic_square"])) { _UserImage = (string)mm["pic_square"]; // get user image } } catch //(Exception ex) // commented by Ud to remove warning { } } Users objUsers = new Users( txtUsername.Text.Trim(), _Pass, txtFirstName.Text, txtLastName.Text, txtEmail.Text, "", chkAgreeReceiveNewsletters.Checked, txtCity.Text, state, int.Parse(ddlCountry.SelectedValue), usertype,facebookUid,ApplicationType ); objUsers.UserImage = _UserImage; UserBusiness objUserBus = new UserBusiness(); //Check for Personal Account. //Check for Business Account. if (rdoBusinessAccount.Checked) { objUserBus.Website = txtWebsiteAddress.Text; objUserBus.CompanyName = txtBusinessName.Text; objUserBus.BusinessType = int.Parse(ddlBusinessType.SelectedValue); objUserBus.BusinessAddress = txtStreetAddress.Text; objUserBus.ZipCode = txtZipCode.Text; objUserBus.Phone = txtPhoneNumber1.Text + txtPhoneNumber2.Text + txtPhoneNumber3.Text; objUserReg.UserBusiness = objUserBus; } objUserReg.Users = objUsers; return objUserReg; }
// // GET: /Account/Register //[FacebookAuthorize(LoginUrl = "/Account/Register")] public ActionResult Register() { if (User.Identity.IsAuthenticated) return RedirectToAction("Index", "Home"); RegisterModel model = new RegisterModel(); model.AvatarPath = "../../Content/img/no_avatar.jpg"; if (FacebookWebContext.Current.IsAuthenticated()) { var client = new FacebookWebClient(); dynamic me = client.Query("select name,pic_small, email from user where uid = me()"); model.UserName = me[0].name; model.Email = me[0].email; model.AvatarPath = me[0].pic_small; return View(model); } return View(model); }
protected void lbtnFacebookSignup_Click(object sender, EventArgs e) { var fbWebContext = FacebookWebContext.Current; if (FacebookWebContext.Current.Session != null) { var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken); var me = (IDictionary<string, object>)fbwc.Get("me"); _FacebookUid = fbWebContext.UserId; try { string fbName = (string)me["first_name"] + " " + (string)me["last_name"]; string UserName = fbName.ToLower().Replace(" ", "_").Replace("'", "");/*+ "_"+_FacebookUid.ToString()*/ Nullable<int> state = null; Nullable<int> country = null; string _UserImage = "images/bg_ProfilePhoto.gif"; //if (!string.IsNullOrEmpty(user.pic_square)) string fql = "Select current_location,pic_square,email from user where uid = " + fbWebContext.UserId; JsonArray me2 = (JsonArray)fbwc.Query(fql); var mm = (IDictionary<string, object>)me2[0]; if (!string.IsNullOrEmpty((string)mm["pic_square"])) { _UserImage = (string)mm["pic_square"]; // get user image } string city = ""; if ((JsonObject)mm["current_location"] != null) { JsonObject hl = (JsonObject)mm["current_location"]; city = (string)hl[0]; if (_presenter.GetFacebookStateId((string)hl[2], (string)hl[1]) > 0) { state = _presenter.GetFacebookStateId((string)hl[2], (string)hl[1]); } if (_presenter.GetFacebookCountryId((string)hl[2]) > 0) { country = _presenter.GetFacebookCountryId((string)hl[2]); } } string password_ = string.Empty; _FBEmail = string.Empty; //user.proxied_email; string result = (string)mm["email"]; if (!string.IsNullOrEmpty(result)) { _FBEmail = result; password_ = RandomPassword.Generate(8, 10); password_ = TributePortalSecurity.Security.EncryptSymmetric(password_); } int _email = _presenter.EmailAvailable(); if (_email == 0) { UserRegistration objUserReg = new UserRegistration(); TributesPortal.BusinessEntities.Users objUsers = new TributesPortal.BusinessEntities.Users( UserName, password_, (string)me["first_name"], (string)me["last_name"], _FBEmail, "", false, city, state, country, 1, _FacebookUid, ApplicationType); objUsers.UserImage = _UserImage; // objUsers.ApplicationType = ApplicationType; objUserReg.Users = objUsers; /*System.Decimal identity = (System.Decimal)*/ _presenter.DoShortFacebookSignup(objUserReg); if (objUserReg.CustomError != null) { ShowMessage(string.Format("<h2>Sorry, {0}.</h2>" + "<h3>Those Facebook credentials are already used in some other Your Tribute Account</h3>", fbName), "", true); } else { SessionValue _objSessionValue = new SessionValue(objUserReg.Users.UserId, objUserReg.Users.UserName, objUserReg.Users.FirstName, objUserReg.Users.LastName, objUserReg.Users.Email, objUserReg.UserBusiness == null ? 1 : 2, "Basic", objUserReg.Users.IsUsernameVisiable); TributesPortal.Utilities.StateManager stateManager = TributesPortal.Utilities.StateManager.Instance; stateManager.Add("objSessionvalue", _objSessionValue, TributesPortal.Utilities.StateManager.State.Session); SaveSessionInDB(); Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", Session.SessionID)); Response.Cookies["ASP.NET_SessionId"].Domain = "." + WebConfig.TopLevelDomain; RedirectPage(); return; } } else { ShowMessage(headertext, "User already exists for this email: " + _FBEmail, true);//COMDIFFRES: is this message correct? _showSignUpDialog = "false"; } } catch (Exception ex) { ShowMessage(headertext, ex.Message, true); _showSignUpDialog = "false"; // killFacebookCookies(); // ShowMessage("Your Facebook session has timed out. Please logout and try again"); } } }
protected void Page_Load(object sender, EventArgs e) { this.Header.DataBind(); // Code to implement SSL Functionality. //if (!WebConfig.ApplicationMode.Equals("local")) //if (Request.Url.ToString().Contains(@"http://")) // Response.Redirect(@"https://www." + WebConfig.TopLevelDomain + @"/adminprofilesettings.aspx"); this.Master.NavPrimary = Shared_InnerSecure.AdminNavPrimaryEnum.myprofile.ToString(); this.Master.NavSecondary = Shared_InnerSecure.AdminNavSecondaryEnum.profile.ToString(); this.Master.PageTitle = "Profile Settings"; if (!this.IsPostBack) { this._presenter.GetImage(); StateManager stateManagerP = StateManager.Instance; string PageName = "AdminProfileSettings"; stateManagerP.Add(PortalEnums.SessionValueEnum.SearchPageName.ToString(), PageName, StateManager.State.Session); StateManager stateManager = StateManager.Instance; SessionValue objSessionvalue = (SessionValue)stateManager.Get("objSessionvalue", StateManager.State.Session); if (Request["id"] != null && Session["objSessionvalueAdmin"] != null) { //Get Useron UserId //_presenter.() OnAdminLogin(); if (string.IsNullOrEmpty(this.UserName)) { Response.Redirect(Redirect.RedirectToPage(Redirect.PageList.Inner2LoginPage.ToString())); } objSessionvalue = null; objSessionvalue = (SessionValue)stateManager.Get("objSessionvalue", StateManager.State.Session); if (objSessionvalue != null) { OnLoggedIn(objSessionvalue); } } else if (objSessionvalue != null) { OnLoggedIn(objSessionvalue); } else { Response.Redirect(Redirect.RedirectToPage(Redirect.PageList.Inner2LoginPage.ToString())); } } else { //set _userName _userName = LoggedInUserName; } if (HeaderBGColor.Length > 0) { txtColorPicker.Attributes.Add("value", HeaderBGColor); txtColorPicker.Style.Add(HtmlTextWriterStyle.Color, HeaderBGColor); } else { txtColorPicker.Attributes.Add("value", WebConfig.DefaultColorPickerValue); txtColorPicker.Style.Add(HtmlTextWriterStyle.Color, WebConfig.DefaultColorPickerValue); } if (FacebookWebContext.Current.Session != null) { if (FacebookWebContext.Current.AccessToken != null) { var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken); try { string fql = "Select pic_square from user where uid = " + FacebookWebContext.Current.UserId; JsonArray me2 = (JsonArray) fbwc.Query(fql); var mm = (IDictionary<string, object>) me2[0]; if (!string.IsNullOrEmpty((string) mm["pic_square"])) { ImgUserImage.Src = (string) mm["pic_square"]; // get user image } } catch (Exception ex) { } } } }
/// <summary> /// udham attri: function to set values for user object /// </summary> /// <returns>object userRegistration </returns> private UserRegistration SaveAccount() { int Usertype = 1; UserRegistration objUserReg = new UserRegistration(); string _Pass = TributePortalSecurity.Security.EncryptSymmetric(txtPassword.Text.ToLower().ToString()); string _UserImage = "images/bg_ProfilePhoto.gif"; Nullable<Int64> _FacebookUid = null; var fbwebContext = FacebookWebContext.Current; if (FacebookWebContext.Current.Session != null) { _FacebookUid = fbwebContext.UserId; try { var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken); string fql = "Select pic_square from user where uid = " + fbwebContext.UserId; JsonArray me2 = (JsonArray)fbwc.Query(fql); var mm = (IDictionary<string, object>)me2[0]; if (!string.IsNullOrEmpty((string)mm["pic_square"])) { _UserImage = (string)mm["pic_square"]; // get user image } } catch (Exception ex) { } } TributesPortal.BusinessEntities.Users objUsers = new TributesPortal.BusinessEntities.Users( txtEmail.Text.Trim(), _Pass, txtFirstName.Text.ToString(), txtLastName.Text.ToString(), txtEmail.Text.ToString(), "", chkAgreeReceiveNewsletters.Checked, "", null, int.Parse(ddlCountry.SelectedValue.ToString()), Usertype, _FacebookUid ); objUsers.ApplicationType = ApplicationType; objUsers.UserImage = _UserImage; objUserReg.Users = objUsers; return objUserReg; }
public ActionResult Index() { var app = new FacebookWebClient(); var fbContext = FacebookWebContext.Current; ViewData["FirstRun"] = false; TennisUserModel existingUser = ModelUtils.GetTennisUsers(this.DB).Where(tu => tu.FacebookId == fbContext.UserId).FirstOrDefault(); if (null == existingUser && null != fbContext.SignedRequest) { if (!fbContext.SignedRequest.Data.ContainsKey("registration")) { return new RedirectResult("/home/register"); } var regInfo = (JsonObject)fbContext.SignedRequest.Data["registration"]; long locationId; City city = GetCity(regInfo, out locationId); double timeZoneOffset = 0; JsonArray users = (JsonArray)app.Query("SELECT timezone FROM user WHERE uid = " + fbContext.UserId); if (null != users && users.Count > 0) { dynamic userData = users[0]; timeZoneOffset = Convert.ToDouble(userData.timezone); } if (null == city) { JsonArray places = (JsonArray)app.Query("SELECT latitude,longitude FROM place WHERE page_id = " + locationId); if (null != places && places.Count > 0) { JsonObject location = regInfo.GetValue<JsonObject>("location"); dynamic place = places[0]; city = new City(); city.LocationId = location.GetValue<long>("id"); city.Name = location.GetValue<string>("name"); city.Latitude = Convert.ToDouble(place.latitude); city.Longitude = Convert.ToDouble(place.longitude); this.DB.City.InsertOnSubmit(city); } } User user = new User(); user.FacebookId = fbContext.UserId; user.Name = regInfo.GetValue<string>("name"); user.Email = regInfo.GetValue<string>("email"); user.Birthday = regInfo.GetValue<DateTime>("birthday"); user.Gender = regInfo.GetValue<string>("gender") == "male"; user.City = city; user.TimeZoneOffset = timeZoneOffset; user.EmailOffers = true; TennisUser tennisUser = new TennisUser(); tennisUser.FacebookId = fbContext.UserId; tennisUser.Rating = regInfo.GetValue<double>("NTRPRating"); tennisUser.SinglesDoubles = regInfo.GetValue<string>("SinglesDoubles"); tennisUser.CurrentAvailability = true; this.DB.User.InsertOnSubmit(user); this.DB.TennisUser.InsertOnSubmit(tennisUser); this.DB.SubmitChanges(); return new RedirectResult(Facebook.FacebookApplication.Current.ReturnUrlPath + "?fr=1"); } if (null == existingUser) { return new RedirectResult("/home/register"); } if (!string.IsNullOrEmpty(Request["fr"])) { ViewData["FirstRun"] = true; } ViewData.Model = new IndexModel(existingUser, this.DB); ViewData["Action"] = "Index"; return View("~/Views/Home/Index.aspx"); }