本文整理汇总了C#中mojoPortal.Business.SiteUser.SetRegistrationConfirmationGuid方法的典型用法代码示例。如果您正苦于以下问题:C# SiteUser.SetRegistrationConfirmationGuid方法的具体用法?C# SiteUser.SetRegistrationConfirmationGuid怎么用?C# SiteUser.SetRegistrationConfirmationGuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mojoPortal.Business.SiteUser
的用法示例。
在下文中一共展示了SiteUser.SetRegistrationConfirmationGuid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoNewUserLogic
private void DoNewUserLogic(OpenIdEventArgs e)
{
if (e == null) { return; }
ClaimsResponse claim = e.Response.GetExtension<ClaimsResponse>();
if (claim == null) { return; }
if (IsValidForUserCreation(e, claim))
{
if (SiteUser.EmailExistsInDB(siteSettings.SiteId, claim.Email))
{
// show message that user should login and associate
// their open id account on their profile page.
lblError.Text = Resource.OpenIDRegisterUserEmailExistsMessage;
return;
}
else
{
// create user automagically since we have all
// the needed data
SiteUser newUser = new SiteUser(siteSettings);
newUser.Email = claim.Email;
newUser.Name = claim.FullName;
string loginName = newUser.Name.Replace(" ", ".").ToLower();
if (loginName.Length > 50) loginName = loginName.Substring(0, 50);
if (SiteUser.LoginExistsInDB(
siteSettings.SiteId, loginName))
{
loginName = e.ClaimedIdentifier.ToString().Replace("http://", string.Empty).Replace("https://", string.Empty).Replace("/", string.Empty);
if (loginName.Length > 50) loginName = loginName.Substring(0, 50);
int i = 1;
while (SiteUser.LoginExistsInDB(
siteSettings.SiteId, loginName))
{
loginName += i.ToString();
if (loginName.Length > 50) loginName = loginName.Remove(40, 1);
i++;
}
}
newUser.LoginName = loginName;
newUser.Password = SiteUser.CreateRandomPassword(7, WebConfigSettings.PasswordGeneratorChars);
newUser.PasswordQuestion = Resource.ManageUsersDefaultSecurityQuestion;
newUser.PasswordAnswer = Resource.ManageUsersDefaultSecurityAnswer;
newUser.OpenIdUri = e.ClaimedIdentifier.ToString();
newUser.Save();
if (siteSettings.UseSecureRegistration)
{
newUser.SetRegistrationConfirmationGuid(Guid.NewGuid());
}
// track user ip address
UserLocation userLocation = new UserLocation(newUser.UserGuid, SiteUtils.GetIP4Address());
userLocation.SiteGuid = siteSettings.SiteGuid;
userLocation.Hostname = Page.Request.UserHostName;
userLocation.Save();
if (
(siteSettings.UseSecureRegistration)
&& (newUser.RegisterConfirmGuid != Guid.Empty)
)
{
Notification.SendRegistrationConfirmationLink(
SiteUtils.GetSmtpSettings(),
ResourceHelper.GetMessageTemplate("RegisterConfirmEmailMessage.config"),
siteSettings.DefaultEmailFromAddress,
siteSettings.DefaultFromEmailAlias,
newUser.Email,
siteSettings.SiteName,
WebUtils.GetSiteRoot() + "/ConfirmRegistration.aspx?ticket=" +
newUser.RegisterConfirmGuid.ToString());
lblError.Text = Resource.LoginUnconfirmedEmailMessage;
log.Info("Automatically created User " + newUser.Name + " on login from open id. Tried to login but email address is not confirmed.");
return;
}
if (siteSettings.UseEmailForLogin)
{
FormsAuthentication.SetAuthCookie(
newUser.Email, true);
}
else
{
FormsAuthentication.SetAuthCookie(
newUser.LoginName, true);
}
if (WebConfigSettings.UseFoldersInsteadOfHostnamesForMultipleSites)
{
string cookieName = "siteguid" + siteSettings.SiteGuid;
CookieHelper.SetCookie(cookieName, newUser.UserGuid.ToString(), true);
}
newUser.UpdateLastLoginTime();
//.........这里部分代码省略.........
示例2: CreateUser
private void CreateUser(string windowsLiveId)
{
SiteUser newUser = new SiteUser(siteSettings);
newUser.WindowsLiveId = windowsLiveId;
newUser.Name = SecurityHelper.RemoveMarkup(txtUserName.Text);
newUser.LoginName = newUser.Name;
newUser.Email = txtEmail.Text;
mojoMembershipProvider mojoMembership = (mojoMembershipProvider)Membership.Provider;
newUser.Password = mojoMembership.EncodePassword(siteSettings, newUser, SiteUser.CreateRandomPassword(7, WebConfigSettings.PasswordGeneratorChars));
//newUser.Password = SiteUser.CreateRandomPassword(7);
newUser.PasswordQuestion = Resource.ManageUsersDefaultSecurityQuestion;
newUser.PasswordAnswer = Resource.ManageUsersDefaultSecurityAnswer;
newUser.Save();
if (siteSettings.UseSecureRegistration)
{
newUser.SetRegistrationConfirmationGuid(Guid.NewGuid());
}
mojoProfileConfiguration profileConfig
= mojoProfileConfiguration.GetConfig();
// set default values first
foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
{
#if!MONO
// we are using the new TimeZoneInfo list but it doesn't work under Mono
// this makes us skip the TimeOffsetHours setting from mojoProfile.config which is not used under windows
if (propertyDefinition.Name == mojoProfilePropertyDefinition.TimeOffsetHoursKey) { continue; }
#endif
mojoProfilePropertyDefinition.SavePropertyDefault(
newUser, propertyDefinition);
}
foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
{
#if!MONO
// we are using the new TimeZoneInfo list but it doesn't work under Mono
// this makes us skip the TimeOffsetHours setting from mojoProfile.config which is not used under windows
if (propertyDefinition.Name == mojoProfilePropertyDefinition.TimeOffsetHoursKey) { continue; }
#endif
if ((propertyDefinition.RequiredForRegistration)||(propertyDefinition.ShowOnRegistration))
{
mojoProfilePropertyDefinition.SaveProperty(
newUser,
pnlRequiredProfileProperties,
propertyDefinition,
timeOffset,
timeZone);
}
}
// track user ip address
UserLocation userLocation = new UserLocation(newUser.UserGuid, SiteUtils.GetIP4Address());
userLocation.SiteGuid = siteSettings.SiteGuid;
userLocation.Hostname = Page.Request.UserHostName;
userLocation.Save();
UserRegisteredEventArgs u = new UserRegisteredEventArgs(newUser);
OnUserRegistered(u);
CacheHelper.ClearMembershipStatisticsCache();
NewsletterHelper.ClaimExistingSubscriptions(newUser);
DoUserLogin(newUser);
}
示例3: CreateUser
private SiteUser CreateUser(
string openId,
string email,
string loginName,
string name,
bool emailIsVerified)
{
SiteUser newUser = new SiteUser(siteSettings);
newUser.Email = email;
if (loginName.Length > 50) loginName = loginName.Substring(0, 50);
int i = 1;
while (SiteUser.LoginExistsInDB(
siteSettings.SiteId, loginName))
{
loginName += i.ToString();
if (loginName.Length > 50) loginName = loginName.Remove(40, 1);
i++;
}
if ((name == null) || (name.Length == 0)) name = loginName;
newUser.LoginName = loginName;
newUser.Name = name;
//newUser.Password = SiteUser.CreateRandomPassword(7);
mojoMembershipProvider mojoMembership = (mojoMembershipProvider)Membership.Provider;
newUser.Password = mojoMembership.EncodePassword(siteSettings, newUser, SiteUser.CreateRandomPassword(7, WebConfigSettings.PasswordGeneratorChars));
newUser.PasswordQuestion = Resource.ManageUsersDefaultSecurityQuestion;
newUser.PasswordAnswer = Resource.ManageUsersDefaultSecurityAnswer;
newUser.OpenIdUri = openId;
newUser.Save();
//test
//emailIsVerified = false;
if (siteSettings.UseSecureRegistration)
{
if (!emailIsVerified)
{
newUser.SetRegistrationConfirmationGuid(Guid.NewGuid());
}
}
mojoProfileConfiguration profileConfig
= mojoProfileConfiguration.GetConfig();
// set default values first
foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
{
#if!MONO
// we are using the new TimeZoneInfo list but it doesn't work under Mono
// this makes us skip the TimeOffsetHours setting from mojoProfile.config which is not used under windows
if (propertyDefinition.Name == mojoProfilePropertyDefinition.TimeOffsetHoursKey) { continue; }
#endif
mojoProfilePropertyDefinition.SavePropertyDefault(
newUser, propertyDefinition);
}
foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
{
#if!MONO
// we are using the new TimeZoneInfo list but it doesn't work under Mono
// this makes us skip the TimeOffsetHours setting from mojoProfile.config which is not used under windows
if (propertyDefinition.Name == mojoProfilePropertyDefinition.TimeOffsetHoursKey) { continue; }
#endif
if ((propertyDefinition.RequiredForRegistration)||(propertyDefinition.ShowOnRegistration))
{
mojoProfilePropertyDefinition.SaveProperty(
newUser,
pnlRequiredProfileProperties,
propertyDefinition,
timeOffset,
timeZone);
}
}
// track user ip address
UserLocation userLocation = new UserLocation(newUser.UserGuid, SiteUtils.GetIP4Address());
userLocation.SiteGuid = siteSettings.SiteGuid;
userLocation.Hostname = Page.Request.UserHostName;
userLocation.Save();
UserRegisteredEventArgs u = new UserRegisteredEventArgs(newUser);
OnUserRegistered(u);
CacheHelper.ClearMembershipStatisticsCache();
// we'll map them next time they login
//OpenIdRpxHelper rpxHelper = new OpenIdRpxHelper(rpxApiKey, rpxBaseUrl);
//rpxHelper.Map(openId, newUser.UserGuid.ToString());
DoSubscribe(newUser);
NewsletterHelper.ClaimExistingSubscriptions(newUser);
return newUser;
}
示例4: CreateUser
private void CreateUser(
string openId,
string email,
string loginName,
string name)
{
SiteUser newUser = new SiteUser(siteSettings);
newUser.Email = email;
if (loginName.Length > 50) loginName = loginName.Substring(0, 50);
int i = 1;
while (SiteUser.LoginExistsInDB(
siteSettings.SiteId, loginName))
{
loginName += i.ToString();
if (loginName.Length > 50) loginName = loginName.Remove(40, 1);
i++;
}
if ((name == null) || (name.Length == 0)) name = loginName;
newUser.LoginName = loginName;
newUser.Name = name;
//newUser.Password = SiteUser.CreateRandomPassword(7);
mojoMembershipProvider mojoMembership = (mojoMembershipProvider)Membership.Provider;
newUser.Password = mojoMembership.EncodePassword(siteSettings, newUser, SiteUser.CreateRandomPassword(7, WebConfigSettings.PasswordGeneratorChars));
newUser.PasswordQuestion = Resource.ManageUsersDefaultSecurityQuestion;
newUser.PasswordAnswer = Resource.ManageUsersDefaultSecurityAnswer;
newUser.OpenIdUri = openId;
newUser.Save();
if (siteSettings.UseSecureRegistration)
{
newUser.SetRegistrationConfirmationGuid(Guid.NewGuid());
}
mojoProfileConfiguration profileConfig
= mojoProfileConfiguration.GetConfig();
// set default values first
foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
{
mojoProfilePropertyDefinition.SavePropertyDefault(
newUser, propertyDefinition);
}
foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
{
if ((propertyDefinition.RequiredForRegistration)||(propertyDefinition.ShowOnRegistration))
{
mojoProfilePropertyDefinition.SaveProperty(
newUser,
pnlRequiredProfileProperties,
propertyDefinition,
timeOffset,
timeZone);
}
}
// track user ip address
UserLocation userLocation = new UserLocation(newUser.UserGuid, SiteUtils.GetIP4Address());
userLocation.SiteGuid = siteSettings.SiteGuid;
userLocation.Hostname = Page.Request.UserHostName;
userLocation.Save();
UserRegisteredEventArgs u = new UserRegisteredEventArgs(newUser);
OnUserRegistered(u);
CacheHelper.ClearMembershipStatisticsCache();
NewsletterHelper.ClaimExistingSubscriptions(newUser);
DoUserLogin(newUser);
}