Skip to content

Commit

Permalink
Updated to fix permission issues with anonymous access. Added missing…
Browse files Browse the repository at this point in the history
… property for pending email.
  • Loading branch information
ccoulson committed Nov 22, 2011
1 parent 19ccbff commit 911fd48
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,24 @@ public static string GetWebProperty(string key, string defaultValue)

public static bool GetSiteProperty(string key, bool defaultValue)
{
return Boolean.Parse(GetWebProperty(key, defaultValue.ToString(), SPContext.Current.Site.RootWeb));
return GetSiteProperty(key, defaultValue, SPContext.Current.Site);
}

public static bool GetSiteProperty(string key, bool defaultValue, SPSite site)
{
return Boolean.Parse(GetWebProperty(key, defaultValue.ToString(), site.RootWeb));
bool result = defaultValue;

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite privSite = new SPSite(site.ID, site.Zone))
{
using (SPWeb web = privSite.RootWeb)
{
result = Boolean.Parse(GetWebProperty(key, defaultValue.ToString(), web));
}
}
});
return result;
}

public static void SetWebProperty(string key, string value, SPWeb web)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ protected override void OnCreatingUser(LoginCancelEventArgs e)
request.LastName = this.LastName;
request.DefaultGroup = this._DefaultGroup;
request.LoginCreatedUser = false;
request.SiteName = web.Title;
request.SiteURL = web.Url;
if (!MembershipRequest.CopyToReviewList(request))
{
lblError.Text = this.UnknownErrorMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,34 +426,31 @@ void _ctlPasswordRecovery_VerifyingUser(object sender, LoginCancelEventArgs e)

void _ctlPasswordRecovery_SendMailError(object sender, SendMailErrorEventArgs e)
{
using (SPSite _site = new SPSite(SPContext.Current.Site.ID, SPContext.Current.Site.Zone))
SPWeb _web = SPContext.Current.Web;

PasswordRecovery prc = (PasswordRecovery)sender;
MembershipUser currentUser = Utils.BaseMembershipProvider(_web.Site).GetUser(prc.UserName, false);
MembershipRequest membershipitem = new MembershipRequest();
membershipitem.UserEmail = currentUser.Email;
membershipitem.UserName = currentUser.UserName;
membershipitem.SiteName = _web.Title;
membershipitem.SiteURL = _web.Url;
membershipitem.PasswordQuestion = currentUser.PasswordQuestion;
membershipitem.Password = currentUser.ResetPassword(prc.Answer);

/* These are the possible set of URLs that are provided to the user and developer in the XSLT */
MembershipSettings settings = new MembershipSettings(_web);
membershipitem.ChangePasswordURL = Utils.GetAbsoluteURL(_web, settings.ChangePasswordPage);
membershipitem.PasswordQuestionURL = Utils.GetAbsoluteURL(_web, settings.PasswordQuestionPage);
membershipitem.ThankYouURL = Utils.GetAbsoluteURL(_web, settings.ThankYouPage);

if (!MembershipRequest.SendPasswordResetEmail(membershipitem, _web))
{
using (SPWeb _web = _site.OpenWeb())
{
PasswordRecovery prc = (PasswordRecovery)sender;
MembershipUser currentUser = Utils.BaseMembershipProvider(_web.Site).GetUser(prc.UserName, false);
MembershipRequest membershipitem = new MembershipRequest();
membershipitem.UserEmail = currentUser.Email;
membershipitem.UserName = currentUser.UserName;
membershipitem.SiteName = _web.Title;
membershipitem.SiteURL = _web.Url;
membershipitem.PasswordQuestion = currentUser.PasswordQuestion;
membershipitem.Password = currentUser.ResetPassword(prc.Answer);

/* These are the possible set of URLs that are provided to the user and developer in the XSLT */
MembershipSettings settings = new MembershipSettings(_web);
membershipitem.ChangePasswordURL = Utils.GetAbsoluteURL(_web, settings.ChangePasswordPage);
membershipitem.PasswordQuestionURL = Utils.GetAbsoluteURL(_web, settings.PasswordQuestionPage);
membershipitem.ThankYouURL = Utils.GetAbsoluteURL(_web, settings.ThankYouPage);

if (!MembershipRequest.SendPasswordResetEmail(membershipitem, _web))
{
TemplateHelper helper = new TemplateHelper(_ctlPasswordRecovery.SuccessTemplateContainer);
helper.SetText("Success", LocalizedString.GetString("FBAPackPasswordRecoveryWebPart", "ErrorSendingEmail"));
}
e.Handled = true;
}
TemplateHelper helper = new TemplateHelper(_ctlPasswordRecovery.SuccessTemplateContainer);
helper.SetText("Success", LocalizedString.GetString("FBAPackPasswordRecoveryWebPart", "ErrorSendingEmail"));
}
e.Handled = true;

}

protected override void CreateChildControls()
Expand Down

0 comments on commit 911fd48

Please sign in to comment.