How to Login automatically in Sitefinity through API
Hi,
Our site has a custom registration page, which works fine, and redirects users to a thank you page.
We need this to automatically log users in.
Here's the registration code:
private void CreateAndRedirect(bool isValidatedMember) var result = this.CreateUser( this.Email.Text, this.Password.Text, this.FirstName.Text, this.LastName.Text, this.Email.Text, string.Empty, string.Empty, true, this.Number.Text, this.Mail.Checked ? "1" : "0", this.Country.Text, isValidatedMember, this.birthdayDay.Text, this.birthdayMonth.SelectedIndex.ToString(CultureInfo.CurrentUICulture), this.birthdayYear.Text); if (result == MembershipCreateStatus.Success) if (isValidatedMember) this.Response.Redirect(this.ResolveUrl("~/members/official-welcome")); else this.Response.Redirect(this.ResolveUrl("~/members/welcome")); The following is working for me:
var validate = SecurityManager.AuthenticateUser("Default", Username.Text, Password.Text, true);
bool authenticated = (validate == UserLoggingReason.Success);Hi Mark
1.var userManager = UserManager.GetManager();2.SecurityManager.AuthenticateUser(userManager.Provider.Name, Email.Text, Password.Text, true, out user);3.//Request.IsAuthenticated is true here4.Response.Redirect("/welcome");5.//6.//Welcome page7.//Response.Redirect = false;