/// <summary> /// Creates the facebook user /// </summary> /// <param name="facebookUser"> /// The facebook user. /// </param> /// <param name="userGender"> /// The user gender. /// </param> /// <param name="message"> /// The message. /// </param> /// <returns> /// Returns if the login was successfully or not /// </returns> private static bool CreateFacebookUser(FacebookUser facebookUser, int userGender, out string message) { if (BoardContext.Current.Get <BoardSettings>().DisableRegistrations) { message = BoardContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } // Check user for bot var isPossibleSpamBot = false; var userIpAddress = BoardContext.Current.Get <HttpRequestBase>().GetUserRealIPAddress(); // Check content for spam if (BoardContext.Current.Get <ISpamCheck>().CheckUserForSpamBot(facebookUser.UserName, facebookUser.Email, userIpAddress, out var result)) { BoardContext.Current.Get <ILogger>().Log( null, "Bot Detected", $"Bot Check detected a possible SPAM BOT: (user name : '{facebookUser.UserName}', email : '{facebookUser.Email}', ip: '{userIpAddress}', reason : {result}), user was rejected.", EventLogTypes.SpamBotDetected); if (BoardContext.Current.Get <BoardSettings>().BotHandlingOnRegister.Equals(1)) { // Flag user as spam bot isPossibleSpamBot = true; } else if (BoardContext.Current.Get <BoardSettings>().BotHandlingOnRegister.Equals(2)) { message = BoardContext.Current.Get <ILocalization>().GetText("BOT_MESSAGE"); if (!BoardContext.Current.Get <BoardSettings>().BanBotIpOnDetection) { return(false); } BoardContext.Current.GetRepository <BannedIP>() .Save( null, userIpAddress, $"A spam Bot who was trying to register was banned by IP {userIpAddress}", BoardContext.Current.PageUserID); // Clear cache BoardContext.Current.Get <IDataCache>().Remove(Constants.Cache.BannedIP); if (BoardContext.Current.Get <BoardSettings>().LogBannedIP) { BoardContext.Current.Get <ILogger>() .Log( null, "IP BAN of Bot During Registration", $"A spam Bot who was trying to register was banned by IP {userIpAddress}", EventLogTypes.IpBanSet); } return(false); } } var memberShipProvider = BoardContext.Current.Get <MembershipProvider>(); var pass = Membership.GeneratePassword(32, 16); var securityAnswer = Membership.GeneratePassword(64, 30); var user = memberShipProvider.CreateUser( facebookUser.UserName, pass, facebookUser.Email, memberShipProvider.RequiresQuestionAndAnswer ? "Answer is a generated Pass" : null, memberShipProvider.RequiresQuestionAndAnswer ? securityAnswer : null, true, null, out var status); // setup initial roles (if any) for this user RoleMembershipHelper.SetupUserRoles(BoardContext.Current.PageBoardID, facebookUser.UserName); // create the user in the YAF DB as well as sync roles... var userID = RoleMembershipHelper.CreateForumUser(user, BoardContext.Current.PageBoardID); // create empty profile just so they have one var userProfile = YafUserProfile.GetProfile(facebookUser.UserName); // setup their initial profile information userProfile.Save(); userProfile.Facebook = facebookUser.ProfileURL; userProfile.FacebookId = facebookUser.UserID; userProfile.Homepage = facebookUser.ProfileURL; if (facebookUser.Birthday.IsSet()) { var ci = CultureInfo.CreateSpecificCulture("en-US"); DateTime.TryParse(facebookUser.Birthday, ci, DateTimeStyles.None, out var userBirthdate); if (userBirthdate > DateTimeHelper.SqlDbMinTime().Date) { userProfile.Birthday = userBirthdate; } } userProfile.RealName = facebookUser.Name; userProfile.Gender = userGender; if (facebookUser.Location != null && facebookUser.Location.Name.IsSet()) { userProfile.Location = facebookUser.Location.Name; } if (BoardContext.Current.Get <BoardSettings>().EnableIPInfoService) { var userIpLocator = BoardContext.Current.Get <IIpInfoService>().GetUserIpLocator(); if (userIpLocator != null) { userProfile.Country = userIpLocator["CountryCode"]; } } userProfile.Save(); // setup their initial profile information userProfile.Save(); if (userID == null) { // something is seriously wrong here -- redirect to failure... message = BoardContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } if (BoardContext.Current.Get <BoardSettings>().NotificationOnUserRegisterEmailList.IsSet()) { // send user register notification to the following admin users... BoardContext.Current.Get <ISendNotification>().SendRegistrationNotificationEmail(user, userID.Value); } if (isPossibleSpamBot) { BoardContext.Current.Get <ISendNotification>().SendSpamBotNotificationToAdmins(user, userID.Value); } // send user register notification to the user... BoardContext.Current.Get <ISendNotification>() .SendRegistrationNotificationToUser(user, pass, securityAnswer, "NOTIFICATION_ON_FACEBOOK_REGISTER"); // save the time zone... var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey); var autoWatchTopicsEnabled = BoardContext.Current.Get <BoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; BoardContext.Current.GetRepository <User>().Save( userId, BoardContext.Current.PageBoardID, facebookUser.UserName, facebookUser.UserName, facebookUser.Email, TimeZoneInfo.Local.Id, null, null, null, null, BoardContext.Current.Get <BoardSettings>().DefaultNotificationSetting, autoWatchTopicsEnabled, TimeZoneInfo.Local.SupportsDaylightSavingTime, null, null); // save the settings... BoardContext.Current.GetRepository <User>().SaveNotification( userId, true, autoWatchTopicsEnabled, BoardContext.Current.Get <BoardSettings>().DefaultNotificationSetting.ToInt(), BoardContext.Current.Get <BoardSettings>().DefaultSendDigestEmail); // save avatar BoardContext.Current.GetRepository <User>().SaveAvatar( userId, $"https://graph.facebook.com/v3.3/{facebookUser.UserID}/picture", null, null); BoardContext.Current.Get <IRaiseEvent>().Raise(new NewUserRegisteredEvent(user, userId)); SingleSignOnUser.LoginSuccess(AuthService.facebook, user.UserName, userId, true); message = string.Empty; return(true); }
/// <summary> /// Handles the Click event of the ForumRegister control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void ForumRegisterClick([NotNull] object sender, [NotNull] EventArgs e) { if (!this.Page.IsValid) { return; } var newEmail = this.Email.Text.Trim(); var newUsername = this.UserName.Text.Trim(); if (!ValidationHelper.IsValidEmail(newEmail)) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_REGUSER", "MSG_INVALID_MAIL")); return; } if (UserMembershipHelper.UserExists(this.UserName.Text.Trim(), newEmail)) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_REGUSER", "MSG_NAME_EXISTS")); return; } MembershipCreateStatus status; var user = this.Get <MembershipProvider>() .CreateUser( newUsername, this.Password.Text.Trim(), newEmail, this.Question.Text.Trim(), this.Answer.Text.Trim(), !this.Get <YafBoardSettings>().EmailVerification, null, out status); if (status != MembershipCreateStatus.Success) { // error of some kind this.PageContext.AddLoadMessage(this.GetText("ADMIN_REGUSER", "MSG_ERROR_CREATE").FormatWith(status)); return; } // setup inital roles (if any) for this user RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, newUsername); // create the user in the YAF DB as well as sync roles... var userId = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID); // create profile var userProfile = YafUserProfile.GetProfile(newUsername); // setup their inital profile information userProfile.Location = this.Location.Text.Trim(); userProfile.Homepage = this.HomePage.Text.Trim(); userProfile.Save(); var autoWatchTopicsEnabled = this.Get <YafBoardSettings>() .DefaultNotificationSetting.Equals(UserNotificationSetting.TopicsIPostToOrSubscribeTo); // save the time zone... LegacyDb.user_save( UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey), this.PageContext.PageBoardID, null, null, null, this.TimeZones.SelectedValue.ToType <int>(), null, null, null, null, null, null, this.Get <YafBoardSettings>().DefaultNotificationSetting, autoWatchTopicsEnabled, null, null, null); if (this.Get <YafBoardSettings>().EmailVerification) { this.Get <ISendNotification>().SendVerificationEmail(user, newEmail, userId, newUsername); } LegacyDb.user_savenotification( UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey), true, autoWatchTopicsEnabled, this.Get <YafBoardSettings>().DefaultNotificationSetting, this.Get <YafBoardSettings>().DefaultSendDigestEmail); // success this.PageContext.AddLoadMessage( this.GetText("ADMIN_REGUSER", "MSG_CREATED").FormatWith(this.UserName.Text.Trim())); YafBuildLink.Redirect(ForumPages.admin_reguser); }
/// <summary> /// Creates the Google user /// </summary> /// <param name="googleUser">The Google user.</param> /// <param name="userGender">The user gender.</param> /// <param name="message">The message.</param> /// <returns> /// Returns if the login was successfully or not /// </returns> private bool CreateGoogleUser(GoogleUser googleUser, int userGender, out string message) { if (YafContext.Current.Get <YafBoardSettings>().DisableRegistrations) { message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } // Check user for bot var spamChecker = new YafSpamCheck(); string result; var isPossibleSpamBot = false; var userIpAddress = YafContext.Current.Get <HttpRequestBase>().GetUserRealIPAddress(); // Check content for spam if (spamChecker.CheckUserForSpamBot(googleUser.UserName, googleUser.Email, userIpAddress, out result)) { YafContext.Current.Get <ILogger>().Log( null, "Bot Detected", "Bot Check detected a possible SPAM BOT: (user name : '{0}', email : '{1}', ip: '{2}', reason : {3}), user was rejected." .FormatWith(googleUser.UserName, googleUser.Email, userIpAddress, result), EventLogTypes.SpamBotDetected); if (YafContext.Current.Get <YafBoardSettings>().BotHandlingOnRegister.Equals(1)) { // Flag user as spam bot isPossibleSpamBot = true; } else if (YafContext.Current.Get <YafBoardSettings>().BotHandlingOnRegister.Equals(2)) { message = YafContext.Current.Get <ILocalization>().GetText("BOT_MESSAGE"); if (!YafContext.Current.Get <YafBoardSettings>().BanBotIpOnDetection) { return(false); } YafContext.Current.GetRepository <BannedIP>() .Save( null, userIpAddress, "A spam Bot who was trying to register was banned by IP {0}".FormatWith(userIpAddress), YafContext.Current.PageUserID); // Clear cache YafContext.Current.Get <IDataCache>().Remove(Constants.Cache.BannedIP); if (YafContext.Current.Get <YafBoardSettings>().LogBannedIP) { YafContext.Current.Get <ILogger>() .Log( null, "IP BAN of Bot During Registration", "A spam Bot who was trying to register was banned by IP {0}".FormatWith( userIpAddress), EventLogTypes.IpBanSet); } return(false); } } MembershipCreateStatus status; var pass = Membership.GeneratePassword(32, 16); var securityAnswer = Membership.GeneratePassword(64, 30); MembershipUser user = YafContext.Current.Get <MembershipProvider>() .CreateUser( googleUser.UserName, pass, googleUser.Email, "Answer is a generated Pass", securityAnswer, true, null, out status); // setup inital roles (if any) for this user RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, googleUser.UserName); // create the user in the YAF DB as well as sync roles... int?userID = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID); // create empty profile just so they have one YafUserProfile userProfile = YafUserProfile.GetProfile(googleUser.UserName); userProfile.Google = googleUser.ProfileURL; userProfile.GoogleId = googleUser.UserID; userProfile.Homepage = googleUser.ProfileURL; userProfile.Gender = userGender; userProfile.Save(); // setup their inital profile information userProfile.Save(); if (userID == null) { // something is seriously wrong here -- redirect to failure... message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } if (YafContext.Current.Get <YafBoardSettings>().NotificationOnUserRegisterEmailList.IsSet()) { // send user register notification to the following admin users... YafSingleSignOnUser.SendRegistrationNotificationEmail(user, userID.Value); } if (isPossibleSpamBot) { YafSingleSignOnUser.SendSpamBotNotificationToAdmins(user, userID.Value); } // send user register notification to the user... YafContext.Current.Get <ISendNotification>() .SendRegistrationNotificationToUser(user, pass, securityAnswer, "NOTIFICATION_ON_GOOGLE_REGISTER"); // save the time zone... int userId = UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey); LegacyDb.user_save( userId, YafContext.Current.PageBoardID, googleUser.UserName, googleUser.UserName, googleUser.Email, 0, null, null, true, null, null, null, null, null, null, null, null); bool autoWatchTopicsEnabled = YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; // save the settings... LegacyDb.user_savenotification( userId, true, autoWatchTopicsEnabled, YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting, YafContext.Current.Get <YafBoardSettings>().DefaultSendDigestEmail); // save avatar LegacyDb.user_saveavatar(userId, googleUser.ProfileImage, null, null); YafContext.Current.Get <IRaiseEvent>().Raise(new NewUserRegisteredEvent(user, userId)); YafSingleSignOnUser.LoginSuccess(AuthService.google, user.UserName, userId, true); message = string.Empty; return(true); }
/// <summary> /// Creates the or assign twitter user. /// </summary> /// <param name="twitterUser"> /// The twitter user. /// </param> /// <param name="oAuth"> /// The oAUTH. /// </param> /// <param name="message"> /// The message. /// </param> /// <returns> /// Returns if the login was successfully or not /// </returns> private static bool CreateTwitterUser(TwitterUser twitterUser, OAuthTwitter oAuth, out string message) { if (YafContext.Current.Get <BoardSettings>().DisableRegistrations) { message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } // Create User if not exists?! Doesn't work because there is no Email var email = $"{twitterUser.UserName}@twitter.com"; // Check user for bot /*var spamChecker = new YafSpamCheck(); * string result; * var isPossibleSpamBot = false; * * var userIpAddress = YafContext.Current.Get<HttpRequestBase>().GetUserRealIPAddress(); * * // Check content for spam * if (spamChecker.CheckUserForSpamBot(twitterUser.UserName, twitterUser.Email, userIpAddress, out result)) * { * YafContext.Current.Get<ILogger>().Log( * null, * "Bot Detected", * "Bot Check detected a possible SPAM BOT: (user name : '{0}', email : '{1}', ip: '{2}', reason : {3}), user was rejected." * .FormatWith(twitterUser.UserName, twitterUser.Email, userIpAddress, result), * EventLogTypes.SpamBotDetected); * * if (YafContext.Current.Get<BoardSettings>().BotHandlingOnRegister.Equals(1)) * { * // Flag user as spam bot * isPossibleSpamBot = true; * } * else if (YafContext.Current.Get<BoardSettings>().BotHandlingOnRegister.Equals(2)) * { * message = YafContext.Current.Get<ILocalization>().GetText("BOT_MESSAGE"); * * if (!YafContext.Current.Get<BoardSettings>().BanBotIpOnDetection) * { * return false; * } * * YafContext.Current.GetRepository<BannedIP>() * .Save( * null, * userIpAddress, * "A spam Bot who was trying to register was banned by IP {0}".FormatWith(userIpAddress), * YafContext.Current.PageUserID); * * // Clear cache * YafContext.Current.Get<IDataCache>().Remove(Constants.Cache.BannedIP); * * if (YafContext.Current.Get<BoardSettings>().LogBannedIP) * { * YafContext.Current.Get<ILogger>() * .Log( * null, * "IP BAN of Bot During Registration", * "A spam Bot who was trying to register was banned by IP {0}".FormatWith( * userIpAddress), * EventLogTypes.IpBanSet); * } * * return false; * } * }*/ // Create User if not exists?! var memberShipProvider = YafContext.Current.Get <MembershipProvider>(); var pass = Membership.GeneratePassword(32, 16); var securityAnswer = Membership.GeneratePassword(64, 30); var user = memberShipProvider.CreateUser( twitterUser.UserName, pass, email, memberShipProvider.RequiresQuestionAndAnswer ? "Answer is a generated Pass" : null, memberShipProvider.RequiresQuestionAndAnswer ? securityAnswer : null, true, null, out var status); // setup initial roles (if any) for this user RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, twitterUser.UserName); // create the user in the YAF DB as well as sync roles... var userID = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID); // create empty profile just so they have one var userProfile = YafUserProfile.GetProfile(twitterUser.UserName); // setup their initial profile information userProfile.Save(); userProfile.TwitterId = twitterUser.UserId.ToString(); userProfile.Twitter = twitterUser.UserName; userProfile.Homepage = twitterUser.Url.IsSet() ? twitterUser.Url : $"http://twitter.com/{twitterUser.UserName}"; userProfile.RealName = twitterUser.Name; userProfile.Interests = twitterUser.Description; userProfile.Location = twitterUser.Location; if (YafContext.Current.Get <BoardSettings>().EnableIPInfoService) { var userIpLocator = YafContext.Current.Get <IIpInfoService>().GetUserIpLocator(); if (userIpLocator != null) { userProfile.Country = userIpLocator["CountryCode"]; var location = new StringBuilder(); if (userIpLocator["RegionName"] != null && userIpLocator["RegionName"].IsSet() && !userIpLocator["RegionName"].Equals("-")) { location.Append(userIpLocator["RegionName"]); } if (userIpLocator["CityName"] != null && userIpLocator["CityName"].IsSet() && !userIpLocator["CityName"].Equals("-")) { location.AppendFormat(", {0}", userIpLocator["CityName"]); } userProfile.Location = location.ToString(); } } userProfile.Save(); if (userID == null) { // something is seriously wrong here -- redirect to failure... message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_TWITTER_FAILED"); return(false); } if (YafContext.Current.Get <BoardSettings>().NotificationOnUserRegisterEmailList.IsSet()) { // send user register notification to the following admin users... YafContext.Current.Get <ISendNotification>().SendRegistrationNotificationEmail(user, userID.Value); } // save the time zone... var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey); // send user register notification to the following admin users... SendRegistrationMessageToTwitterUser(user, pass, securityAnswer, userId, oAuth); var autoWatchTopicsEnabled = YafContext.Current.Get <BoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; YafContext.Current.GetRepository <User>().Save( userId, YafContext.Current.PageBoardID, twitterUser.UserName, twitterUser.UserName, email, TimeZoneInfo.Local.Id, null, null, null, null, null, YafContext.Current.Get <BoardSettings>().DefaultNotificationSetting, autoWatchTopicsEnabled, TimeZoneInfo.Local.SupportsDaylightSavingTime, null, null); // save the settings... YafContext.Current.GetRepository <User>().SaveNotification( userId, true, autoWatchTopicsEnabled, YafContext.Current.Get <BoardSettings>().DefaultNotificationSetting, YafContext.Current.Get <BoardSettings>().DefaultSendDigestEmail); // save avatar if (twitterUser.ProfileImageUrl.IsSet()) { YafContext.Current.GetRepository <User>().SaveAvatar(userId, twitterUser.ProfileImageUrl, null, null); } LoginTwitterSuccess(true, oAuth, userId, user); message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "UPDATE_EMAIL"); return(true); }
/// <summary> /// Sends Notifications to Moderators that Message Needs Approval /// </summary> /// <param name="forumId">The forum id.</param> /// <param name="newMessageId">The new message id.</param> /// <param name="isSpamMessage">if set to <c>true</c> [is spam message].</param> public void ToModeratorsThatMessageNeedsApproval(int forumId, int newMessageId, bool isSpamMessage) { var moderatorsFiltered = this.Get <YafDbBroker>().GetAllModerators().Where(f => f.ForumID.Equals(forumId)); var moderatorUserNames = new List <string>(); moderatorsFiltered.ForEach( moderator => { if (moderator.IsGroup) { moderatorUserNames.AddRange(this.Get <RoleProvider>().GetUsersInRole(moderator.Name)); } else { moderatorUserNames.Add(moderator.Name); } }); // send each message... moderatorUserNames.Distinct().ForEach( userName => { // add each member of the group var membershipUser = UserMembershipHelper.GetUser(userName); var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(membershipUser.ProviderUserKey); var languageFile = UserHelper.GetUserLanguageFile(userId); var subject = string.Format( this.Get <ILocalization>().GetText( "COMMON", isSpamMessage ? "NOTIFICATION_ON_MODERATOR_SPAMMESSAGE_APPROVAL" : "NOTIFICATION_ON_MODERATOR_MESSAGE_APPROVAL", languageFile), this.BoardSettings.Name); var notifyModerators = new YafTemplateEmail( isSpamMessage ? "NOTIFICATION_ON_MODERATOR_SPAMMESSAGE_APPROVAL" : "NOTIFICATION_ON_MODERATOR_MESSAGE_APPROVAL") { // get the user localization... TemplateLanguageFile = languageFile, TemplateParams = { ["{adminlink}"] = YafBuildLink.GetLinkNotEscaped( ForumPages.moderate_unapprovedposts, true, "f={0}", forumId), ["{forumname}"] = this.BoardSettings.Name } }; notifyModerators.SendEmail( new MailAddress(membershipUser.Email, membershipUser.UserName), subject, true); }); }
/// <summary> /// Import the User From the Current Table Row /// </summary> /// <param name="row"> /// The row with the User Information. /// </param> /// <param name="importCount"> /// The import Count. /// </param> /// <returns> /// Returns the Imported User Count. /// </returns> private int ImportUser(DataRow row, int importCount) { // Also Check if the Email is unique and exists if (this.Get <MembershipProvider>().RequiresUniqueEmail) { if (this.Get <MembershipProvider>().GetUserNameByEmail((string)row["Email"]) != null) { return(importCount); } } MembershipCreateStatus status; var pass = Membership.GeneratePassword(32, 16); var securityAnswer = Membership.GeneratePassword(64, 30); var securityQuestion = "Answer is a generated Pass"; if (row.Table.Columns.Contains("Password") && !string.IsNullOrEmpty((string)row["Password"]) && row.Table.Columns.Contains("SecurityQuestion") && !string.IsNullOrEmpty((string)row["SecurityQuestion"]) && row.Table.Columns.Contains("SecurityAnswer") && !string.IsNullOrEmpty((string)row["SecurityAnswer"])) { pass = (string)row["Password"]; securityAnswer = (string)row["SecurityAnswer"]; securityQuestion = (string)row["SecurityQuestion"]; } var user = YafContext.Current.Get <MembershipProvider>().CreateUser( (string)row["Name"], pass, (string)row["Email"], this.Get <MembershipProvider>().RequiresQuestionAndAnswer ? securityQuestion : null, this.Get <MembershipProvider>().RequiresQuestionAndAnswer ? securityAnswer : null, true, null, out status); // setup inital roles (if any) for this user RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, (string)row["Name"]); // create the user in the YAF DB as well as sync roles... int?userID = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID); // create empty profile just so they have one YafUserProfile userProfile = YafUserProfile.GetProfile((string)row["Name"]); // Add Profile Fields to User List Table. if (row.Table.Columns.Contains("RealName") && !string.IsNullOrEmpty((string)row["RealName"])) { userProfile.RealName = (string)row["RealName"]; } if (row.Table.Columns.Contains("Blog") && !string.IsNullOrEmpty((string)row["Blog"])) { userProfile.Blog = (string)row["Blog"]; } if (row.Table.Columns.Contains("Gender") && !string.IsNullOrEmpty((string)row["Gender"])) { int gender; int.TryParse((string)row["Gender"], out gender); userProfile.Gender = gender; } if (row.Table.Columns.Contains("Birthday") && !string.IsNullOrEmpty((string)row["Birthday"])) { DateTime userBirthdate; DateTime.TryParse((string)row["Birthday"], out userBirthdate); if (userBirthdate > DateTimeHelper.SqlDbMinTime()) { userProfile.Birthday = userBirthdate; } } if (row.Table.Columns.Contains("MSN") && !string.IsNullOrEmpty((string)row["MSN"])) { userProfile.MSN = (string)row["MSN"]; } if (row.Table.Columns.Contains("BlogServiceUsername") && !string.IsNullOrEmpty((string)row["BlogServiceUsername"])) { userProfile.BlogServiceUsername = (string)row["BlogServiceUsername"]; } if (row.Table.Columns.Contains("BlogServicePassword") && !string.IsNullOrEmpty((string)row["BlogServicePassword"])) { userProfile.BlogServicePassword = (string)row["BlogServicePassword"]; } if (row.Table.Columns.Contains("AIM") && !string.IsNullOrEmpty((string)row["AIM"])) { userProfile.AIM = (string)row["AIM"]; } if (row.Table.Columns.Contains("Google") && !string.IsNullOrEmpty((string)row["Google"])) { userProfile.Google = (string)row["Google"]; } if (row.Table.Columns.Contains("GoogleId") && !string.IsNullOrEmpty((string)row["GoogleId"])) { userProfile.GoogleId = (string)row["GoogleId"]; } if (row.Table.Columns.Contains("Location") && !string.IsNullOrEmpty((string)row["Location"])) { userProfile.Location = (string)row["Location"]; } if (row.Table.Columns.Contains("Country") && !string.IsNullOrEmpty((string)row["Country"])) { userProfile.Country = (string)row["Country"]; } if (row.Table.Columns.Contains("Region") && !string.IsNullOrEmpty((string)row["Region"])) { userProfile.Region = (string)row["Region"]; } if (row.Table.Columns.Contains("City") && !string.IsNullOrEmpty((string)row["City"])) { userProfile.City = (string)row["City"]; } if (row.Table.Columns.Contains("Interests") && !string.IsNullOrEmpty((string)row["Interests"])) { userProfile.Interests = (string)row["Interests"]; } if (row.Table.Columns.Contains("Homepage") && !string.IsNullOrEmpty((string)row["Homepage"])) { userProfile.Homepage = (string)row["Homepage"]; } if (row.Table.Columns.Contains("Skype") && !string.IsNullOrEmpty((string)row["Skype"])) { userProfile.Skype = (string)row["Skype"]; } if (row.Table.Columns.Contains("ICQe") && !string.IsNullOrEmpty((string)row["ICQ"])) { userProfile.ICQ = (string)row["ICQ"]; } if (row.Table.Columns.Contains("XMPP") && !string.IsNullOrEmpty((string)row["XMPP"])) { userProfile.XMPP = (string)row["XMPP"]; } if (row.Table.Columns.Contains("YIM") && !string.IsNullOrEmpty((string)row["YIM"])) { userProfile.YIM = (string)row["YIM"]; } if (row.Table.Columns.Contains("Occupation") && !string.IsNullOrEmpty((string)row["Occupation"])) { userProfile.Occupation = (string)row["Occupation"]; } if (row.Table.Columns.Contains("Twitter") && !string.IsNullOrEmpty((string)row["Twitter"])) { userProfile.Twitter = (string)row["Twitter"]; } if (row.Table.Columns.Contains("TwitterId") && !string.IsNullOrEmpty((string)row["TwitterId"])) { userProfile.TwitterId = (string)row["TwitterId"]; } if (row.Table.Columns.Contains("Facebook") && !string.IsNullOrEmpty((string)row["Facebook"])) { userProfile.Facebook = (string)row["Facebook"]; } if (row.Table.Columns.Contains("FacebookId") && !string.IsNullOrEmpty((string)row["FacebookId"])) { userProfile.FacebookId = (string)row["FacebookId"]; } userProfile.Save(); if (userID == null) { // something is seriously wrong here -- redirect to failure... return(importCount); } // send user register notification to the new users this.Get <ISendNotification>().SendRegistrationNotificationToUser( user, pass, securityAnswer, "NOTIFICATION_ON_REGISTER"); // save the time zone... var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey); var isDST = false; if (row.Table.Columns.Contains("IsDST") && !string.IsNullOrEmpty((string)row["IsDST"])) { bool.TryParse((string)row["IsDST"], out isDST); } var timeZone = 0; if (row.Table.Columns.Contains("Timezone") && !string.IsNullOrEmpty((string)row["Timezone"])) { int.TryParse((string)row["Timezone"], out timeZone); } LegacyDb.user_save( userId, YafContext.Current.PageBoardID, row["Name"], row.Table.Columns.Contains("DisplayName") ? row["DisplayName"] : null, row["Email"], timeZone, row.Table.Columns.Contains("LanguageFile") ? row["LanguageFile"] : null, row.Table.Columns.Contains("Culture") ? row["Culture"] : null, row.Table.Columns.Contains("ThemeFile") ? row["ThemeFile"] : null, row.Table.Columns.Contains("TextEditor") ? row["TextEditor"] : null, null, null, null, null, isDST, null, null); var autoWatchTopicsEnabled = this.Get <YafBoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; // save the settings... LegacyDb.user_savenotification( userId, true, autoWatchTopicsEnabled, this.Get <YafBoardSettings>().DefaultNotificationSetting, this.Get <YafBoardSettings>().DefaultSendDigestEmail); importCount++; return(importCount); }
/// <summary> /// Creates the Google user /// </summary> /// <param name="googleUser"> /// The Google user. /// </param> /// <param name="userGender"> /// The user gender. /// </param> /// <param name="message"> /// The message. /// </param> /// <returns> /// Returns if the login was successfully or not /// </returns> private static bool CreateGoogleUser(GoogleUser googleUser, int userGender, out string message) { if (YafContext.Current.Get <YafBoardSettings>().DisableRegistrations) { message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } // Check user for bot var isPossibleSpamBot = false; var userIpAddress = YafContext.Current.Get <HttpRequestBase>().GetUserRealIPAddress(); // Check content for spam if (YafContext.Current.Get <ISpamCheck>().CheckUserForSpamBot(googleUser.UserName, googleUser.Email, userIpAddress, out var result)) { YafContext.Current.Get <ILogger>().Log( null, "Bot Detected", $"Bot Check detected a possible SPAM BOT: (user name : '{googleUser.UserName}', email : '{googleUser.Email}', ip: '{userIpAddress}', reason : {result}), user was rejected.", EventLogTypes.SpamBotDetected); if (YafContext.Current.Get <YafBoardSettings>().BotHandlingOnRegister.Equals(1)) { // Flag user as spam bot isPossibleSpamBot = true; } else if (YafContext.Current.Get <YafBoardSettings>().BotHandlingOnRegister.Equals(2)) { message = YafContext.Current.Get <ILocalization>().GetText("BOT_MESSAGE"); if (!YafContext.Current.Get <YafBoardSettings>().BanBotIpOnDetection) { return(false); } YafContext.Current.GetRepository <BannedIP>() .Save( null, userIpAddress, $"A spam Bot who was trying to register was banned by IP {userIpAddress}", YafContext.Current.PageUserID); // Clear cache YafContext.Current.Get <IDataCache>().Remove(Constants.Cache.BannedIP); if (YafContext.Current.Get <YafBoardSettings>().LogBannedIP) { YafContext.Current.Get <ILogger>() .Log( null, "IP BAN of Bot During Registration", $"A spam Bot who was trying to register was banned by IP {userIpAddress}", EventLogTypes.IpBanSet); } return(false); } } var memberShipProvider = YafContext.Current.Get <MembershipProvider>(); var pass = Membership.GeneratePassword(32, 16); var securityAnswer = Membership.GeneratePassword(64, 30); var user = memberShipProvider.CreateUser( googleUser.UserName, pass, googleUser.Email, memberShipProvider.RequiresQuestionAndAnswer ? "Answer is a generated Pass" : null, memberShipProvider.RequiresQuestionAndAnswer ? securityAnswer : null, true, null, out var status); // setup initial roles (if any) for this user RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, googleUser.UserName); // create the user in the YAF DB as well as sync roles... var userID = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID); // create empty profile just so they have one var userProfile = YafUserProfile.GetProfile(googleUser.UserName); // setup their initial profile information userProfile.Save(); userProfile.GoogleId = googleUser.UserID; userProfile.Homepage = googleUser.ProfileURL; userProfile.Gender = userGender; if (YafContext.Current.Get <YafBoardSettings>().EnableIPInfoService) { var userIpLocator = YafContext.Current.Get <IIpInfoService>().GetUserIpLocator(); if (userIpLocator != null) { userProfile.Country = userIpLocator["CountryCode"]; var location = new StringBuilder(); if (userIpLocator["RegionName"] != null && userIpLocator["RegionName"].IsSet() && !userIpLocator["RegionName"].Equals("-")) { location.Append(userIpLocator["RegionName"]); } if (userIpLocator["CityName"] != null && userIpLocator["CityName"].IsSet() && !userIpLocator["CityName"].Equals("-")) { location.AppendFormat(", {0}", userIpLocator["CityName"]); } userProfile.Location = location.ToString(); } } userProfile.Save(); if (userID == null) { // something is seriously wrong here -- redirect to failure... message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } if (YafContext.Current.Get <YafBoardSettings>().NotificationOnUserRegisterEmailList.IsSet()) { // send user register notification to the following admin users... YafContext.Current.Get <ISendNotification>().SendRegistrationNotificationEmail(user, userID.Value); } if (isPossibleSpamBot) { YafContext.Current.Get <ISendNotification>().SendSpamBotNotificationToAdmins(user, userID.Value); } // send user register notification to the user... YafContext.Current.Get <ISendNotification>() .SendRegistrationNotificationToUser(user, pass, securityAnswer, "NOTIFICATION_ON_GOOGLE_REGISTER"); // save the time zone... var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey); var autoWatchTopicsEnabled = YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; YafContext.Current.GetRepository <User>().Save( userId, YafContext.Current.PageBoardID, googleUser.UserName, googleUser.UserName, googleUser.Email, TimeZoneInfo.Local.Id, null, null, null, null, null, YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting, autoWatchTopicsEnabled, TimeZoneInfo.Local.SupportsDaylightSavingTime, null, null); // save the settings... YafContext.Current.GetRepository <User>().SaveNotification( userId, true, autoWatchTopicsEnabled, YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting, YafContext.Current.Get <YafBoardSettings>().DefaultSendDigestEmail); // save avatar YafContext.Current.GetRepository <User>().SaveAvatar(userId, googleUser.ProfileImage, null, null); YafContext.Current.Get <IRaiseEvent>().Raise(new NewUserRegisteredEvent(user, userId)); YafSingleSignOnUser.LoginSuccess(AuthService.google, user.UserName, userId, true); message = string.Empty; return(true); }
/// <summary> /// The create user wizard 1_ next button click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void CreateUserWizard1_NextButtonClick([NotNull] object sender, [NotNull] WizardNavigationEventArgs e) { if (this.CreateUserWizard1.WizardSteps[e.CurrentStepIndex].ID != "profile") { return; } // this is the "Profile Information" step. Save the data to their profile (+ defaults). var timeZones = (DropDownList)this.CreateUserWizard1.FindWizardControlRecursive("TimeZones"); var country = (DropDownList)this.CreateUserWizard1.FindWizardControlRecursive("Country"); var locationTextBox = (TextBox)this.CreateUserWizard1.FindWizardControlRecursive("Location"); var homepageTextBox = (TextBox)this.CreateUserWizard1.FindWizardControlRecursive("Homepage"); var dstUser = (CheckBox)this.CreateUserWizard1.FindWizardControlRecursive("DSTUser"); MembershipUser user = UserMembershipHelper.GetUser(this.CreateUserWizard1.UserName); // setup/save the profile YafUserProfile userProfile = YafUserProfile.GetProfile(this.CreateUserWizard1.UserName); if (country.SelectedValue != null) { userProfile.Country = country.SelectedValue; } userProfile.Location = locationTextBox.Text.Trim(); userProfile.Homepage = homepageTextBox.Text.Trim(); userProfile.Save(); // save the time zone... int userId = UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey); LegacyDb.user_save( userID: userId, boardID: this.PageContext.PageBoardID, userName: null, displayName: null, email: null, timeZone: timeZones.SelectedValue.ToType <int>(), languageFile: null, culture: null, themeFile: null, textEditor: null, useMobileTheme: null, approved: null, pmNotification: null, autoWatchTopics: null, dSTUser: dstUser.Checked, hideUser: null, notificationType: null); bool autoWatchTopicsEnabled = this.Get <YafBoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; // save the settings... LegacyDb.user_savenotification( userId, true, autoWatchTopicsEnabled, this.Get <YafBoardSettings>().DefaultNotificationSetting, this.Get <YafBoardSettings>().DefaultSendDigestEmail); // Clearing cache with old Active User Lazy Data ... this.Get <IRaiseEvent>().Raise(new NewUserRegisteredEvent(user, userId)); }
/// <summary> /// Creates the or assign twitter user. /// </summary> /// <param name="twitterUser">The twitter user.</param> /// <param name="oAuth">The oAUTH.</param> /// <param name="message">The message.</param> /// <returns> /// Returns if the login was successfully or not /// </returns> private static bool CreateTwitterUser(TwitterUser twitterUser, OAuthTwitter oAuth, out string message) { if (YafContext.Current.Get <YafBoardSettings>().DisableRegistrations) { message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } // Create User if not exists?! Doesnt work because there is no Email var email = "{0}@twitter.com".FormatWith(twitterUser.UserName); // Create User if not exists?! MembershipCreateStatus status; var pass = Membership.GeneratePassword(32, 16); var securityAnswer = Membership.GeneratePassword(64, 30); MembershipUser user = YafContext.Current.Get <MembershipProvider>() .CreateUser( twitterUser.UserName, pass, email, "Answer is a generated Pass", securityAnswer, true, null, out status); // setup inital roles (if any) for this user RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, twitterUser.UserName); // create the user in the YAF DB as well as sync roles... int?userID = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID); // create empty profile just so they have one YafUserProfile userProfile = YafUserProfile.GetProfile(twitterUser.UserName); userProfile.TwitterId = twitterUser.UserId.ToString(); userProfile.Twitter = twitterUser.UserName; userProfile.Homepage = twitterUser.Url.IsSet() ? twitterUser.Url : "http://twitter.com/{0}".FormatWith(twitterUser.UserName); userProfile.RealName = twitterUser.Name; userProfile.Interests = twitterUser.Description; userProfile.Location = twitterUser.Location; userProfile.Save(); // setup their inital profile information userProfile.Save(); if (userID == null) { // something is seriously wrong here -- redirect to failure... message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_TWITTER_FAILED"); return(false); } if (YafContext.Current.Get <YafBoardSettings>().NotificationOnUserRegisterEmailList.IsSet()) { // send user register notification to the following admin users... YafSingleSignOnUser.SendRegistrationNotificationEmail(user); } // save the time zone... int userId = UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey); // send user register notification to the following admin users... SendRegistrationMessageToTwitterUser(user, pass, securityAnswer, userId, oAuth); LegacyDb.user_save( userId, YafContext.Current.PageBoardID, twitterUser.UserName, null, email, 0, null, null, null, null, null, null, null, null, null, null, null); bool autoWatchTopicsEnabled = YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; // save the settings... LegacyDb.user_savenotification( userId, true, autoWatchTopicsEnabled, YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting, YafContext.Current.Get <YafBoardSettings>().DefaultSendDigestEmail); // save avatar if (twitterUser.ProfileImageUrl.IsSet()) { LegacyDb.user_saveavatar(userId, twitterUser.ProfileImageUrl, null, null); } LoginTwitterSuccess(true, oAuth, userId, user); message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "UPDATE_EMAIL"); return(true); }
/// <summary> /// Sends Notifications to Moderators that a Message was Reported /// </summary> /// <param name="pageForumID"> /// The page Forum ID. /// </param> /// <param name="reportedMessageId"> /// The reported message id. /// </param> /// <param name="reporter"> /// The reporter. /// </param> /// <param name="reportText"> /// The report Text. /// </param> public void ToModeratorsThatMessageWasReported( int pageForumID, int reportedMessageId, int reporter, string reportText) { try { var moderatorsFiltered = this.Get <YafDbBroker>().GetAllModerators().Where(f => f.ForumID.Equals(pageForumID)); var moderatorUserNames = new List <string>(); foreach (var moderator in moderatorsFiltered) { if (moderator.IsGroup) { moderatorUserNames.AddRange(this.Get <RoleProvider>().GetUsersInRole(moderator.Name)); } else { moderatorUserNames.Add(moderator.Name); } } // send each message... foreach (var userName in moderatorUserNames.Distinct()) { // add each member of the group var membershipUser = UserMembershipHelper.GetUser(userName); var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(membershipUser.ProviderUserKey); var languageFile = UserHelper.GetUserLanguageFile(userId); var subject = this.Get <ILocalization>() .GetText("COMMON", "NOTIFICATION_ON_MODERATOR_REPORTED_MESSAGE", languageFile) .FormatWith(this.BoardSettings.Name); var notifyModerators = new YafTemplateEmail("NOTIFICATION_ON_MODERATOR_REPORTED_MESSAGE") { // get the user localization... TemplateLanguageFile = languageFile, TemplateParams = { ["{reason}"] = reportText, ["{reporter}"] = this.Get <IUserDisplayName>().GetName(reporter), ["{adminlink}"] = YafBuildLink.GetLinkNotEscaped( ForumPages.moderate_reportedposts, true, "f={0}", pageForumID), ["{forumname}"] = this.BoardSettings.Name } }; notifyModerators.SendEmail( new MailAddress(membershipUser.Email, membershipUser.UserName), subject, true); } } catch (Exception x) { // report exception to the forum's event log this.Get <ILogger>() .Error( x, "Send Message Report Notification Error for UserID {0}".FormatWith( YafContext.Current.PageUserID)); } }
/// <summary> /// Creates the facebook user /// </summary> /// <param name="facebookUser">The facebook user.</param> /// <param name="userGender">The user gender.</param> /// <param name="message">The message.</param> /// <returns> /// Returns if the login was successfully or not /// </returns> private bool CreateFacebookUser(FacebookUser facebookUser, int userGender, out string message) { if (YafContext.Current.Get <YafBoardSettings>().DisableRegistrations) { message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } MembershipCreateStatus status; var pass = Membership.GeneratePassword(32, 16); var securityAnswer = Membership.GeneratePassword(64, 30); MembershipUser user = YafContext.Current.Get <MembershipProvider>() .CreateUser( facebookUser.UserName, pass, facebookUser.Email, "Answer is a generated Pass", securityAnswer, true, null, out status); // setup inital roles (if any) for this user RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, facebookUser.UserName); // create the user in the YAF DB as well as sync roles... int?userID = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID); // create empty profile just so they have one YafUserProfile userProfile = YafUserProfile.GetProfile(facebookUser.UserName); userProfile.Facebook = facebookUser.ProfileURL; userProfile.FacebookId = facebookUser.UserID; userProfile.Homepage = facebookUser.ProfileURL; if (facebookUser.Birthday.IsSet()) { DateTime userBirthdate; var ci = CultureInfo.CreateSpecificCulture("en-US"); DateTime.TryParse(facebookUser.Birthday, ci, DateTimeStyles.None, out userBirthdate); if (userBirthdate > DateTimeHelper.SqlDbMinTime().Date) { userProfile.Birthday = userBirthdate; } } userProfile.RealName = facebookUser.Name; userProfile.Gender = userGender; if (facebookUser.Location != null && facebookUser.Location.Name.IsSet()) { userProfile.Location = facebookUser.Location.Name; } userProfile.Save(); // setup their inital profile information userProfile.Save(); if (userID == null) { // something is seriously wrong here -- redirect to failure... message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } if (YafContext.Current.Get <YafBoardSettings>().NotificationOnUserRegisterEmailList.IsSet()) { // send user register notification to the following admin users... YafSingleSignOnUser.SendRegistrationNotificationEmail(user, userID.Value); } // send user register notification to the user... YafContext.Current.Get <ISendNotification>() .SendRegistrationNotificationToUser(user, pass, securityAnswer, "NOTIFICATION_ON_FACEBOOK_REGISTER"); // save the time zone... int userId = UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey); LegacyDb.user_save( userId, YafContext.Current.PageBoardID, facebookUser.UserName, facebookUser.UserName, facebookUser.Email, 0, null, null, true, null, null, null, null, null, null, null, null); bool autoWatchTopicsEnabled = YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; // save the settings... LegacyDb.user_savenotification( userId, true, autoWatchTopicsEnabled, YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting, YafContext.Current.Get <YafBoardSettings>().DefaultSendDigestEmail); // save avatar LegacyDb.user_saveavatar( userId, "https://graph.facebook.com/{0}/picture".FormatWith(facebookUser.UserID), null, null); YafContext.Current.Get <IRaiseEvent>().Raise(new NewUserRegisteredEvent(user, userId)); YafSingleSignOnUser.LoginSuccess(AuthService.facebook, user.UserName, userId, true); message = string.Empty; return(true); }
protected void ForumRegister_Click(object sender, System.EventArgs e) { if (Page.IsValid) { string newEmail = Email.Text.Trim(); string newUsername = UserName.Text.Trim(); if (!General.IsValidEmail(newEmail)) { PageContext.AddLoadMessage("You have entered an illegal e-mail address."); return; } if (UserMembershipHelper.UserExists(UserName.Text.Trim(), newEmail)) { PageContext.AddLoadMessage("Username or email are already registered."); return; } string hashinput = DateTime.Now.ToString() + newEmail + Security.CreatePassword(20); string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(hashinput, "md5"); MembershipCreateStatus status; MembershipUser user = Membership.CreateUser(newUsername, Password.Text.Trim(), newEmail, Question.Text.Trim(), Answer.Text.Trim(), !PageContext.BoardSettings.EmailVerification, out status); if (status != MembershipCreateStatus.Success) { // error of some kind PageContext.AddLoadMessage("Membership Error Creating User: "******"VERIFYEMAIL"); verifyEmail.TemplateParams ["{link}"] = String.Format("{1}{0}", YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.approve, "k={0}", hash), YAF.Classes.Utils.YafForumInfo.ServerURL); verifyEmail.TemplateParams ["{key}"] = hash; verifyEmail.TemplateParams ["{forumname}"] = PageContext.BoardSettings.Name; verifyEmail.TemplateParams ["{forumlink}"] = String.Format("{0}", ForumURL); string subject = String.Format(PageContext.Localization.GetText("COMMON", "EMAILVERIFICATION_SUBJECT"), PageContext.BoardSettings.Name); verifyEmail.SendEmail(new System.Net.Mail.MailAddress(newEmail, newUsername), subject, true); } // success PageContext.AddLoadMessage(string.Format("User {0} Created Successfully.", UserName.Text.Trim())); YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.admin_reguser); } }
/// <summary> /// Import the User From the Current Table Row /// </summary> /// <param name="row"> /// The row with the User Information. /// </param> /// <param name="importCount"> /// The import Count. /// </param> /// <returns> /// Returns the Imported User Count. /// </returns> private int ImportUser(DataRow row, int importCount) { // Also Check if the Email is unique and exists if (this.Get <MembershipProvider>().RequiresUniqueEmail) { if (this.Get <MembershipProvider>().GetUserNameByEmail(email: (string)row[columnName: "Email"]) != null) { return(importCount); } } MembershipCreateStatus status; var pass = Membership.GeneratePassword(length: 32, numberOfNonAlphanumericCharacters: 16); var securityAnswer = Membership.GeneratePassword(length: 64, numberOfNonAlphanumericCharacters: 30); var securityQuestion = "Answer is a generated Pass"; if (row.Table.Columns.Contains(name: "Password") && ((string)row[columnName : "Password"]).IsSet() && row.Table.Columns.Contains(name : "SecurityQuestion") && ((string)row[columnName : "SecurityQuestion"]).IsSet() && row.Table.Columns.Contains(name : "SecurityAnswer") && ((string)row[columnName : "SecurityAnswer"]).IsSet()) { pass = (string)row[columnName : "Password"]; securityAnswer = (string)row[columnName : "SecurityAnswer"]; securityQuestion = (string)row[columnName : "SecurityQuestion"]; } var user = YafContext.Current.Get <MembershipProvider>().CreateUser( username: (string)row[columnName: "Name"], password: pass, email: (string)row[columnName: "Email"], passwordQuestion: this.Get <MembershipProvider>().RequiresQuestionAndAnswer ? securityQuestion : null, passwordAnswer: this.Get <MembershipProvider>().RequiresQuestionAndAnswer ? securityAnswer : null, isApproved: true, providerUserKey: null, status: out status); // setup initial roles (if any) for this user RoleMembershipHelper.SetupUserRoles(pageBoardID: YafContext.Current.PageBoardID, userName: (string)row[columnName: "Name"]); // create the user in the YAF DB as well as sync roles... var userID = RoleMembershipHelper.CreateForumUser(user: user, pageBoardID: YafContext.Current.PageBoardID); // create empty profile just so they have one var userProfile = YafUserProfile.GetProfile(userName: (string)row[columnName: "Name"]); // Add Profile Fields to User List Table. if (row.Table.Columns.Contains(name: "RealName") && ((string)row[columnName : "RealName"]).IsSet()) { userProfile.RealName = (string)row[columnName : "RealName"]; } if (row.Table.Columns.Contains(name: "Blog") && ((string)row[columnName : "Blog"]).IsSet()) { userProfile.Blog = (string)row[columnName : "Blog"]; } if (row.Table.Columns.Contains(name: "Gender") && ((string)row[columnName : "Gender"]).IsSet()) { int gender; int.TryParse(s: (string)row[columnName: "Gender"], result: out gender); userProfile.Gender = gender; } if (row.Table.Columns.Contains(name: "Birthday") && ((string)row[columnName : "Birthday"]).IsSet()) { DateTime userBirthdate; DateTime.TryParse(s: (string)row[columnName: "Birthday"], result: out userBirthdate); if (userBirthdate > DateTimeHelper.SqlDbMinTime()) { userProfile.Birthday = userBirthdate; } } if (row.Table.Columns.Contains(name: "BlogServiceUsername") && ((string)row[columnName : "BlogServiceUsername"]).IsSet()) { userProfile.BlogServiceUsername = (string)row[columnName : "BlogServiceUsername"]; } if (row.Table.Columns.Contains(name: "BlogServicePassword") && ((string)row[columnName : "BlogServicePassword"]).IsSet()) { userProfile.BlogServicePassword = (string)row[columnName : "BlogServicePassword"]; } if (row.Table.Columns.Contains(name: "GoogleId") && ((string)row[columnName : "GoogleId"]).IsSet()) { userProfile.GoogleId = (string)row[columnName : "GoogleId"]; } if (row.Table.Columns.Contains(name: "Location") && ((string)row[columnName : "Location"]).IsSet()) { userProfile.Location = (string)row[columnName : "Location"]; } if (row.Table.Columns.Contains(name: "Country") && ((string)row[columnName : "Country"]).IsSet()) { userProfile.Country = (string)row[columnName : "Country"]; } if (row.Table.Columns.Contains(name: "Region") && ((string)row[columnName : "Region"]).IsSet()) { userProfile.Region = (string)row[columnName : "Region"]; } if (row.Table.Columns.Contains(name: "City") && ((string)row[columnName : "City"]).IsSet()) { userProfile.City = (string)row[columnName : "City"]; } if (row.Table.Columns.Contains(name: "Interests") && ((string)row[columnName : "Interests"]).IsSet()) { userProfile.Interests = (string)row[columnName : "Interests"]; } if (row.Table.Columns.Contains(name: "Homepage") && ((string)row[columnName : "Homepage"]).IsSet()) { userProfile.Homepage = (string)row[columnName : "Homepage"]; } if (row.Table.Columns.Contains(name: "Skype") && ((string)row[columnName : "Skype"]).IsSet()) { userProfile.Skype = (string)row[columnName : "Skype"]; } if (row.Table.Columns.Contains(name: "ICQe") && ((string)row[columnName : "ICQ"]).IsSet()) { userProfile.ICQ = (string)row[columnName : "ICQ"]; } if (row.Table.Columns.Contains(name: "XMPP") && ((string)row[columnName : "XMPP"]).IsSet()) { userProfile.XMPP = (string)row[columnName : "XMPP"]; } if (row.Table.Columns.Contains(name: "Occupation") && ((string)row[columnName : "Occupation"]).IsSet()) { userProfile.Occupation = (string)row[columnName : "Occupation"]; } if (row.Table.Columns.Contains(name: "Twitter") && ((string)row[columnName : "Twitter"]).IsSet()) { userProfile.Twitter = (string)row[columnName : "Twitter"]; } if (row.Table.Columns.Contains(name: "TwitterId") && ((string)row[columnName : "TwitterId"]).IsSet()) { userProfile.TwitterId = (string)row[columnName : "TwitterId"]; } if (row.Table.Columns.Contains(name: "Facebook") && ((string)row[columnName : "Facebook"]).IsSet()) { userProfile.Facebook = (string)row[columnName : "Facebook"]; } if (row.Table.Columns.Contains(name: "FacebookId") && ((string)row[columnName : "FacebookId"]).IsSet()) { userProfile.FacebookId = (string)row[columnName : "FacebookId"]; } userProfile.Save(); if (userID == null) { // something is seriously wrong here -- redirect to failure... return(importCount); } // send user register notification to the new users this.Get <ISendNotification>().SendRegistrationNotificationToUser( user: user, pass: pass, securityAnswer: securityAnswer, templateName: "NOTIFICATION_ON_REGISTER"); // save the time zone... var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(providerUserKey: user.ProviderUserKey); var isDst = false; if (row.Table.Columns.Contains(name: "IsDST") && ((string)row[columnName : "IsDST"]).IsSet()) { bool.TryParse(value : (string)row[columnName : "IsDST"], result : out isDst); } var timeZone = 0; if (row.Table.Columns.Contains(name: "Timezone") && ((string)row[columnName : "Timezone"]).IsSet()) { int.TryParse(s : (string)row[columnName : "Timezone"], result : out timeZone); } var autoWatchTopicsEnabled = this.Get <YafBoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; this.GetRepository <User>().Save( userID: userId, boardID: YafContext.Current.PageBoardID, userName: row[columnName: "Name"], displayName: row.Table.Columns.Contains(name: "DisplayName") ? row[columnName: "DisplayName"] : null, email: row[columnName: "Email"], timeZone: timeZone, languageFile: row.Table.Columns.Contains(name: "LanguageFile") ? row[columnName: "LanguageFile"] : null, culture: row.Table.Columns.Contains(name: "Culture") ? row[columnName: "Culture"] : null, themeFile: row.Table.Columns.Contains(name: "ThemeFile") ? row[columnName: "ThemeFile"] : null, textEditor: row.Table.Columns.Contains(name: "TextEditor") ? row[columnName: "TextEditor"] : null, approved: null, pmNotification: null, autoWatchTopics: this.Get <YafBoardSettings>().DefaultNotificationSetting, dSTUser: autoWatchTopicsEnabled, hideUser: isDst, notificationType: null, null); // save the settings... this.GetRepository <User>().SaveNotification( userID: userId, pmNotification: true, autoWatchTopics: autoWatchTopicsEnabled, notificationType: this.Get <YafBoardSettings>().DefaultNotificationSetting, dailyDigest: this.Get <YafBoardSettings>().DefaultSendDigestEmail); importCount++; return(importCount); }
/// <summary> /// Sends Notifications to Moderators that Message Needs Approval /// </summary> /// <param name="forumId">The forum id.</param> /// <param name="newMessageId">The new message id.</param> /// <param name="isSpamMessage">if set to <c>true</c> [is spam message].</param> public void ToModeratorsThatMessageNeedsApproval(int forumId, int newMessageId, bool isSpamMessage) { var moderatorsFiltered = this.Get <DataBroker>().GetAllModerators().Where(f => f.ForumID.Equals(forumId)); var moderatorUserNames = new List <string>(); moderatorsFiltered.ForEach( moderator => { if (moderator.IsGroup) { moderatorUserNames.AddRange(this.Get <RoleProvider>().GetUsersInRole(moderator.Name)); } else { moderatorUserNames.Add(moderator.Name); } }); var themeCss = $"{this.Get<BoardSettings>().BaseUrlMask}{this.Get<ITheme>().BuildThemePath("bootstrap-forum.min.css")}"; var forumLink = BoardInfo.ForumURL; var adminLink = BuildLink.GetLinkNotEscaped(ForumPages.Moderate_UnapprovedPosts, true, "f={0}", forumId); var currentContext = HttpContext.Current; // send each message... moderatorUserNames.Distinct().AsParallel().ForAll( userName => { HttpContext.Current = currentContext; try { // add each member of the group var membershipUser = UserMembershipHelper.GetUser(userName); var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(membershipUser.ProviderUserKey); var languageFile = UserHelper.GetUserLanguageFile(userId); var subject = string.Format( this.Get <ILocalization>().GetText( "COMMON", isSpamMessage ? "NOTIFICATION_ON_MODERATOR_SPAMMESSAGE_APPROVAL" : "NOTIFICATION_ON_MODERATOR_MESSAGE_APPROVAL", languageFile), this.BoardSettings.Name); var notifyModerators = new TemplateEmail( isSpamMessage ? "NOTIFICATION_ON_MODERATOR_SPAMMESSAGE_APPROVAL" : "NOTIFICATION_ON_MODERATOR_MESSAGE_APPROVAL") { TemplateLanguageFile = languageFile, TemplateParams = { ["{user}"] = userName, ["{adminlink}"] = adminLink, ["{themecss}"] = themeCss, ["{forumlink}"] = forumLink } }; notifyModerators.SendEmail( new MailAddress(membershipUser.Email, membershipUser.UserName), subject); } finally { HttpContext.Current = null; } }); }
/// <summary> /// Creates the facebook user /// </summary> /// <param name="facebookUser"> /// The facebook user. /// </param> /// <param name="userGender"> /// The user gender. /// </param> /// <param name="message"> /// The message. /// </param> /// <returns> /// Returns if the login was successfully or not /// </returns> private bool CreateFacebookUser(FacebookUser facebookUser, int userGender, out string message) { if (YafContext.Current.Get <YafBoardSettings>().DisableRegistrations) { message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } // Check user for bot var spamChecker = new YafSpamCheck(); string result; var isPossibleSpamBot = false; var userIpAddress = YafContext.Current.Get <HttpRequestBase>().GetUserRealIPAddress(); // Check content for spam if (spamChecker.CheckUserForSpamBot(facebookUser.UserName, facebookUser.Email, userIpAddress, out result)) { YafContext.Current.Get <ILogger>().Log( null, "Bot Detected", "Bot Check detected a possible SPAM BOT: (user name : '{0}', email : '{1}', ip: '{2}', reason : {3}), user was rejected." .FormatWith(facebookUser.UserName, facebookUser.Email, userIpAddress, result), EventLogTypes.SpamBotDetected); if (YafContext.Current.Get <YafBoardSettings>().BotHandlingOnRegister.Equals(1)) { // Flag user as spam bot isPossibleSpamBot = true; } else if (YafContext.Current.Get <YafBoardSettings>().BotHandlingOnRegister.Equals(2)) { message = YafContext.Current.Get <ILocalization>().GetText("BOT_MESSAGE"); if (!YafContext.Current.Get <YafBoardSettings>().BanBotIpOnDetection) { return(false); } YafContext.Current.GetRepository <BannedIP>() .Save( null, userIpAddress, "A spam Bot who was trying to register was banned by IP {0}".FormatWith(userIpAddress), YafContext.Current.PageUserID); // Clear cache YafContext.Current.Get <IDataCache>().Remove(Constants.Cache.BannedIP); if (YafContext.Current.Get <YafBoardSettings>().LogBannedIP) { YafContext.Current.Get <ILogger>() .Log( null, "IP BAN of Bot During Registration", "A spam Bot who was trying to register was banned by IP {0}".FormatWith( userIpAddress), EventLogTypes.IpBanSet); } return(false); } } MembershipCreateStatus status; var memberShipProvider = YafContext.Current.Get <MembershipProvider>(); var pass = Membership.GeneratePassword(32, 16); var securityAnswer = Membership.GeneratePassword(64, 30); var user = memberShipProvider.CreateUser( facebookUser.UserName, pass, facebookUser.Email, memberShipProvider.RequiresQuestionAndAnswer ? "Answer is a generated Pass" : null, memberShipProvider.RequiresQuestionAndAnswer ? securityAnswer : null, true, null, out status); // setup initial roles (if any) for this user RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, facebookUser.UserName); // create the user in the YAF DB as well as sync roles... var userID = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID); // create empty profile just so they have one var userProfile = YafUserProfile.GetProfile(facebookUser.UserName); // setup their initial profile information userProfile.Save(); userProfile.Facebook = facebookUser.ProfileURL; userProfile.FacebookId = facebookUser.UserID; userProfile.Homepage = facebookUser.ProfileURL; if (facebookUser.Birthday.IsSet()) { DateTime userBirthdate; var ci = CultureInfo.CreateSpecificCulture("en-US"); DateTime.TryParse(facebookUser.Birthday, ci, DateTimeStyles.None, out userBirthdate); if (userBirthdate > DateTimeHelper.SqlDbMinTime().Date) { userProfile.Birthday = userBirthdate; } } userProfile.RealName = facebookUser.Name; userProfile.Gender = userGender; if (facebookUser.Location != null && facebookUser.Location.Name.IsSet()) { userProfile.Location = facebookUser.Location.Name; } if (YafContext.Current.Get <YafBoardSettings>().EnableIPInfoService&& this.UserIpLocator == null) { this.UserIpLocator = new IPDetails().GetData( YafContext.Current.Get <HttpRequestBase>().GetUserRealIPAddress(), "text", false, YafContext.Current.CurrentForumPage.Localization.Culture.Name, string.Empty, string.Empty); if (this.UserIpLocator != null && this.UserIpLocator["StatusCode"] == "OK" && this.UserIpLocator.Count > 0) { userProfile.Country = this.UserIpLocator["CountryCode"]; } } userProfile.Save(); // setup their initial profile information userProfile.Save(); if (userID == null) { // something is seriously wrong here -- redirect to failure... message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } if (YafContext.Current.Get <YafBoardSettings>().NotificationOnUserRegisterEmailList.IsSet()) { // send user register notification to the following admin users... YafContext.Current.Get <ISendNotification>().SendRegistrationNotificationEmail(user, userID.Value); } if (isPossibleSpamBot) { YafContext.Current.Get <ISendNotification>().SendSpamBotNotificationToAdmins(user, userID.Value); } // send user register notification to the user... YafContext.Current.Get <ISendNotification>() .SendRegistrationNotificationToUser(user, pass, securityAnswer, "NOTIFICATION_ON_FACEBOOK_REGISTER"); // save the time zone... var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey); var autoWatchTopicsEnabled = YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; LegacyDb.user_save( userID: userId, boardID: YafContext.Current.PageBoardID, userName: facebookUser.UserName, displayName: facebookUser.UserName, email: facebookUser.Email, timeZone: TimeZoneInfo.Local.Id, languageFile: null, culture: null, themeFile: null, textEditor: null, useMobileTheme: null, approved: null, pmNotification: YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting, autoWatchTopics: autoWatchTopicsEnabled, dSTUser: TimeZoneInfo.Local.SupportsDaylightSavingTime, hideUser: null, notificationType: null); // save the settings... LegacyDb.user_savenotification( userId, true, autoWatchTopicsEnabled, YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting, YafContext.Current.Get <YafBoardSettings>().DefaultSendDigestEmail); // save avatar LegacyDb.user_saveavatar( userId, "https://graph.facebook.com/{0}/picture".FormatWith(facebookUser.UserID), null, null); YafContext.Current.Get <IRaiseEvent>().Raise(new NewUserRegisteredEvent(user, userId)); YafSingleSignOnUser.LoginSuccess(AuthService.facebook, user.UserName, userId, true); message = string.Empty; return(true); }
/// <summary> /// Sends Notifications to Moderators that a Message was Reported /// </summary> /// <param name="pageForumID"> /// The page Forum ID. /// </param> /// <param name="reportedMessageId"> /// The reported message id. /// </param> /// <param name="reporter"> /// The reporter. /// </param> /// <param name="reportText"> /// The report Text. /// </param> public void ToModeratorsThatMessageWasReported( int pageForumID, int reportedMessageId, int reporter, string reportText) { try { var moderatorsFiltered = this.Get <DataBroker>().GetAllModerators().Where(f => f.ForumID.Equals(pageForumID)); var moderatorUserNames = new List <string>(); moderatorsFiltered.ForEach( moderator => { if (moderator.IsGroup) { moderatorUserNames.AddRange(this.Get <RoleProvider>().GetUsersInRole(moderator.Name)); } else { moderatorUserNames.Add(moderator.Name); } }); var currentContext = HttpContext.Current; // send each message... moderatorUserNames.Distinct().AsParallel().ForAll( userName => { HttpContext.Current = currentContext; try { // add each member of the group var membershipUser = UserMembershipHelper.GetUser(userName); var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(membershipUser.ProviderUserKey); var languageFile = UserHelper.GetUserLanguageFile(userId); var subject = string.Format( this.Get <ILocalization>().GetText( "COMMON", "NOTIFICATION_ON_MODERATOR_REPORTED_MESSAGE", languageFile), this.BoardSettings.Name); var notifyModerators = new TemplateEmail("NOTIFICATION_ON_MODERATOR_REPORTED_MESSAGE") { // get the user localization... TemplateLanguageFile = languageFile, TemplateParams = { ["{user}"] = userName, ["{reason}"] = reportText, ["{reporter}"] = this.Get <IUserDisplayName>() .GetName(reporter), ["{adminlink}"] = BuildLink.GetLinkNotEscaped( ForumPages.Moderate_ReportedPosts, true, "f={0}", pageForumID) } }; notifyModerators.SendEmail( new MailAddress(membershipUser.Email, membershipUser.UserName), subject); } finally { HttpContext.Current = null; } }); } catch (Exception x) { // report exception to the forum's event log this.Get <ILogger>().Error( x, $"Send Message Report Notification Error for UserID {BoardContext.Current.PageUserID}"); } }
/// <summary> /// Creates the Google user /// </summary> /// <param name="googleUser">The Google user.</param> /// <param name="userGender">The user gender.</param> /// <param name="message">The message.</param> /// <returns> /// Returns if the login was successfully or not /// </returns> private bool CreateGoogleUser(GoogleUser googleUser, int userGender, out string message) { if (YafContext.Current.Get <YafBoardSettings>().DisableRegistrations) { message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } MembershipCreateStatus status; var pass = Membership.GeneratePassword(32, 16); var securityAnswer = Membership.GeneratePassword(64, 30); MembershipUser user = YafContext.Current.Get <MembershipProvider>() .CreateUser( googleUser.UserName, pass, googleUser.Email, "Answer is a generated Pass", securityAnswer, true, null, out status); // setup inital roles (if any) for this user RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, googleUser.UserName); // create the user in the YAF DB as well as sync roles... int?userID = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID); // create empty profile just so they have one YafUserProfile userProfile = YafUserProfile.GetProfile(googleUser.UserName); userProfile.Google = googleUser.ProfileURL; userProfile.GoogleId = googleUser.UserID; userProfile.Homepage = googleUser.ProfileURL; userProfile.Gender = userGender; userProfile.Save(); // setup their inital profile information userProfile.Save(); if (userID == null) { // something is seriously wrong here -- redirect to failure... message = YafContext.Current.Get <ILocalization>().GetText("LOGIN", "SSO_FAILED"); return(false); } if (YafContext.Current.Get <YafBoardSettings>().NotificationOnUserRegisterEmailList.IsSet()) { // send user register notification to the following admin users... YafSingleSignOnUser.SendRegistrationNotificationEmail(user); } // send user register notification to the user... YafContext.Current.Get <ISendNotification>() .SendRegistrationNotificationToUser(user, pass, securityAnswer, "NOTIFICATION_ON_GOOGLE_REGISTER"); // TODO : LOCALIZE // save the time zone... int userId = UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey); LegacyDb.user_save( userId, YafContext.Current.PageBoardID, googleUser.UserName, googleUser.UserName, googleUser.Email, 0, null, null, true, null, null, null, null, null, null, null, null); bool autoWatchTopicsEnabled = YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; // save the settings... LegacyDb.user_savenotification( userId, true, autoWatchTopicsEnabled, YafContext.Current.Get <YafBoardSettings>().DefaultNotificationSetting, YafContext.Current.Get <YafBoardSettings>().DefaultSendDigestEmail); // save avatar LegacyDb.user_saveavatar(userId, googleUser.ProfileImage, null, null); YafContext.Current.Get <IRaiseEvent>().Raise(new NewUserRegisteredEvent(user, userId)); YafSingleSignOnUser.LoginSuccess(AuthService.google, user.UserName, userId, true); message = string.Empty; return(true); }