Im having a weird problem in an old website running on Umbraco umbraco v 4.0.4.1. Logging in users does not seem to work anymore. I use the following code to log in a user:
string hashedPassword = AmatecWebsite.Extensions.Clients.ClientRepository.verifyHash(txtEmail.Text, txtPassword.Text); Member m = Member.GetMemberFromLoginNameAndPassword(txtEmail.Text, hashedPassword);
//Add the shopping cart if the client has one string sSessionID = OrderManagement.SpecialSessionID(); SessionHandler.CurrentClientID = m.Id;
}
Funny thing is is that logging in as actully succesful but it doesnt seem to be able to remember. So GetMemberFromLoginNameAndPassword actually returns a Member object but IsAuthenticated is always false and so umbraco.library.IsLoggedON() is also always false.
I have also added the line Membership.ValidateUser which returns true, but still umbraco.library:IsLoggedOn() returns false.
I had a userControl with a standard textbox and password field to enable the user to login.
i have now changed this to a standard ASP.Net Login Control and i use the following code to login: <asp:Login ID="login" runat="server" DisplayRememberMe="false" LoginButtonText="Login" LoginButtonStyle-CssClass="knop rechts" OnLoggingIn="Login_OnLoggingIn">
Unable to login user in frontend
Hello,
Im having a weird problem in an old website running on Umbraco umbraco v 4.0.4.1. Logging in users does not seem to work anymore. I use the following code to log in a user:
string hashedPassword = AmatecWebsite.Extensions.Clients.ClientRepository.verifyHash(txtEmail.Text, txtPassword.Text);
Member m = Member.GetMemberFromLoginNameAndPassword(txtEmail.Text, hashedPassword);
if (m != null && txtEmail.Text != string.Empty && txtPassword.Text != string.Empty && hashedPassword != string.Empty)
{
//HttpContext.Current.Response.Write("ja" + ContinueUrl);
Member.AddMemberToCache(m);
//Add the shopping cart if the client has one
string sSessionID = OrderManagement.SpecialSessionID();
SessionHandler.CurrentClientID = m.Id;
}
Funny thing is is that logging in as actully succesful but it doesnt seem to be able to remember. So GetMemberFromLoginNameAndPassword actually returns a Member object but IsAuthenticated is always false and so umbraco.library.IsLoggedON() is also always false.
Does anyone know how i shoudl remeber the user?
thanks in advance.
shameless bump
I think you also need to set the authentication cookie after logging in.
Dave
Hi Dawoe,
Thank you for your reply, i will try your suggestion and get back to with the result.
That also doesnt seem to help, any other ideas?
Looking at this page : http://24days.in/umbraco/2012/creating-a-login-form-with-umbraco-mvc-surfacecontroller
I see it uses MemberShip.ValidateUser. You will probably need to call that too.
Dave
Hi Dave,
I have also added the line Membership.ValidateUser which returns true, but still umbraco.library:IsLoggedOn() returns false.
I had a userControl with a standard textbox and password field to enable the user to login.
i have now changed this to a standard ASP.Net Login Control and i use the following code to login:
<asp:Login ID="login" runat="server" DisplayRememberMe="false" LoginButtonText="Login" LoginButtonStyle-CssClass="knop rechts" OnLoggingIn="Login_OnLoggingIn">
</asp:Login>
protected void Login_OnLoggingIn(object sender, EventArgs e)
{
string hashedPassword = AmatecWebsite.Extensions.Clients.ClientRepository.verifyHash(login.UserName, login.Password);
Member m = Member.GetMemberFromLoginNameAndPassword(login.UserName, hashedPassword);
bool validate = Membership.ValidateUser(login.UserName, hashedPassword);
if (m != null && login.UserName != string.Empty && login.Password != string.Empty && hashedPassword != string.Empty)
{
Member.AddMemberToCache(m);
FormsAuthentication.SetAuthCookie(login.UserName, true);
string sSessionID = OrderManagement.SpecialSessionID();
SessionHandler.CurrentClientID = m.Id;
ShoppingCart.MergeShoppingCarts(sSessionID, m.Id);
AmatecWebsite.Extensions.Orders.ShoppingCartManagement.UpdateItemsInShoppingCartMini();
FormsAuthentication.RedirectFromLoginPage(login.UserName, true);
}
But still umbraco.library:IsLoggedOn is always false.
It almost seems like i should be looking somewhere else?
As the line in my previous suggested: i had to look somewhere else.
My web.config was missing: <authentication mode="Forms" />
When i added that everything worked as it should.
Thanks Dave for your help.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.