protected void OnCreateClick(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid) { string username = TxtLogin.Text.StripHTMLTags().Trim(); if (!string.IsNullOrEmpty(email)) { DataObjectUser.CreateUser(AuthenticationType.FacebookConnect, id, username, email, firstname, lastname, gender); ScriptManager.RegisterStartupScript(this, this.GetType(), "CloseWindow", "$telerik.$(function() { RefreshParentPage();CloseWindow(); } );", true); } } }
private bool DoActivate(string username, string activationCode, bool manualLogin) { bool userCreated = false; MembershipUser membershipUser = Membership.GetUser(username, false); if (membershipUser != null) { string userId = membershipUser.ProviderUserKey.ToString(); AspnetMembership membership = AspnetMembership.FetchByID(new Guid(userId)); if (membership.PasswordQuestion == activationCode || (manualLogin && ConfigurationManager.AppSettings["PromoActivationCode"].ToLower().Trim() == activationCode.ToLower().Trim())) { membership.PasswordQuestion = "-"; membership.Save(); Roles.RemoveUserFromRole(username, "NotActivated"); Roles.AddUserToRole(username, "Basic"); DataObjectUser.CreateUser(UserDataContext.GetUserDataContext(), username); UserProfile userProfile = UserProfile.GetProfile(username); if (userProfile == null) { userProfile = (UserProfile)UserProfile.Create(username); userProfile.UserId = new Guid(membershipUser.ProviderUserKey.ToString()); userProfile.Nickname = username; } Community.CreateUserProfileCommunity(UserDataContext.GetUserDataContext(), userProfile); DataObjectUser.JoinCommunities(userId, _4screen.CSB.Common.SiteConfig.GetSiteContext(UserProfile.Current)); DataObjectUser.AddDefaultFriends(userId); _4screen.CSB.Extensions.Business.IncentivePointsManager.AddIncentivePointEvent("USER_ACTIVATE", UserDataContext.GetUserDataContext()); SetProfileDefaults(new Guid(userId)); userCreated = true; } else if (membership.PasswordQuestion != activationCode) { lblInfo.Text += language.GetString("MessageActivatCodeInvalid"); pnlError.Visible = true; pnlActivate.Visible = false; } } else { lblInfo.Text += language.GetString("MessageActivatUserInvalid"); pnlError.Visible = true; pnlActivate.Visible = false; } return(userCreated); }
protected void IdentitySelectorIconClick(object sender, EventArgs e) { string secXmlToken = Request.Params["SecXmlToken"]; if (!string.IsNullOrEmpty(secXmlToken)) { Token token = new Token(secXmlToken); string ppid = token.Claims[ClaimTypes.PPID]; string firstname = token.Claims[ClaimTypes.GivenName]; string lastname = token.Claims[ClaimTypes.Surname]; string email = token.Claims[ClaimTypes.Email]; string gender = token.Claims[ClaimTypes.Gender]; CSBooster_DataContext csb = new CSBooster_DataContext(Helper.GetSiemeConnectionString()); var user = csb.hisp_DataObject_GetUserIDByOpenID(ppid).ElementAtOrDefault(0); if (user != null) // User exists { MembershipUser membershipUser = Membership.GetUser(user.USR_ID); if (membershipUser != null) { PerformLogin(membershipUser.UserName); } } else // User doesn't exist { if (!string.IsNullOrEmpty(firstname) && !string.IsNullOrEmpty(email)) { if (DataObjectUser.CreateUser(AuthenticationType.InformationCard, ppid, firstname.ToLower(), email, firstname, lastname, gender)) { PerformLogin(firstname.ToLower()); } } } } else { LitInformationCardMsg.Text = language.GetString("MessageInfoCardMissing"); } }
private void HandleOpenIDLogin() { OpenIdClient openID = new OpenIdClient(); switch (openID.RequestedMode) { case RequestedMode.IdResolution: openID.Identity = UserProfile.Current.OpenID; if (openID.ValidateResponse()) { OpenIdUser openIDUser = openID.RetrieveUser(); UserProfile.Current.OpenID = string.Empty; UserProfile.Current.Save(); CSBooster_DataContext csb = new CSBooster_DataContext(Helper.GetSiemeConnectionString()); var user = csb.hisp_DataObject_GetUserIDByOpenID(openIDUser.Identity).ElementAtOrDefault(0); if (user != null) // User exists { MembershipUser membershipUser = Membership.GetUser(user.USR_ID); if (membershipUser != null) { PerformLogin(membershipUser.UserName); } } else // User doesn't exist { string nickname = openIDUser.GetValue("openid.sreg.nickname"); string email = openIDUser.GetValue("openid.sreg.email"); string fullname = openIDUser.GetValue("openid.sreg.fullname") ?? nickname; string gender = openIDUser.GetValue("openid.sreg.gender"); string firstname = string.Empty; string lastname = string.Empty; if (!string.IsNullOrEmpty(nickname) && !string.IsNullOrEmpty(email)) { string[] splitFullname = fullname.Split(' '); if (splitFullname.Length > 0) { firstname = splitFullname[0]; } if (splitFullname.Length > 1) { lastname = splitFullname[1]; } if (DataObjectUser.CreateUser(AuthenticationType.OpenID, openIDUser.Identity, nickname, email, firstname, lastname, gender)) { PerformLogin(nickname); } } else { LitOpenIDMsg.Text = language.GetString("MessageOpenIDNoDataReceived"); } } } else { LitOpenIDMsg.Text = language.GetString("MessageOpenIDLoginNotSuccess"); } break; case RequestedMode.CanceledByUser: LitOpenIDMsg.Text = language.GetString("MessageOpenIDLoginCancel"); break; } }
protected void OnCreateClick(object sender, EventArgs e) { string username = TxtUsername.Text; string password = TxtPassword.Text; string email = TxtEmail.Text; string firstname = TxtFirstname.Text; string lastname = TxtLastname.Text; Regex usernameRegex = new Regex(Constants.REGEX_USERNAME); Regex emailRegex = new Regex(Constants.REGEX_EMAIL); if (string.IsNullOrEmpty(username)) { PnlStatus.Visible = true; LitStatus.Text = "Bitte geben Sie einen Benutzernamen ein"; } else if (!usernameRegex.IsMatch(username)) { PnlStatus.Visible = true; LitStatus.Text = "Bitte geben Sie einen gültigen Benutzernamen ein"; } else if (Membership.GetUser(username) != null) { PnlStatus.Visible = true; LitStatus.Text = "Dieser Benutzername ist bereits besetzt. Bitte geben Sie einen anderen Benutzernamen ein"; } else if (string.IsNullOrEmpty(password)) { PnlStatus.Visible = true; LitStatus.Text = "Bitte geben Sie ein Passwort ein"; } else if (string.IsNullOrEmpty(email)) { PnlStatus.Visible = true; LitStatus.Text = "Bitte geben Sie eine Email-Adresse ein"; } else if (!emailRegex.IsMatch(email)) { PnlStatus.Visible = true; LitStatus.Text = "Bitte geben Sie einen gültige Email-Adresse ein"; } else if (Membership.GetUserNameByEmail(email) != null) { PnlStatus.Visible = true; LitStatus.Text = "Diese Email-Adresse ist bereits besetzt. Bitte geben Sie eine andere Email-Adresse ein"; } else if (DataObjectUser.CreateUser(AuthenticationType.CSBooster, null, username, email, firstname, lastname, null)) { MembershipUser membershipUser = Membership.GetUser(username); string generatedPassword = membershipUser.ResetPassword(); membershipUser.ChangePassword(generatedPassword, password); if (((LinkButton)sender).CommandArgument == "CreateAndLogin") { FormsAuthentication.SetAuthCookie(username, false); Response.Redirect("/"); } else { TxtUsername.Text = string.Empty; TxtEmail.Text = string.Empty; TxtFirstname.Text = string.Empty; TxtLastname.Text = string.Empty; } } else { PnlStatus.Visible = true; LitStatus.Text = "Benutzer konnte nicht erstellt werden"; } }