NopCommerce 2.4 Single SignOn

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Can someone tell me how to do it?

I have another website which I want to use nopCommerce authentication.
I'm already retrieving the nopCommerce logged user and persist in my website, but I can't login into my website using nopCommerce Authentication.

How do I do it?


I changed my Global.asax.cs and my Web.config, including:
configSections>
    <section name="NopConfig" type="Nop.Core.Configuration.NopConfig, Nop.Core" requirePermission="false" />
  </configSections>
  <NopConfig>
    <DynamicDiscovery Enabled="true" />
    <Engine Type="" />
    <Themes basePath="~/Themes/" />
  </NopConfig>

I included Settings.txt in App_Data too.

Thank you,

Allan
12 years ago
Hi,

I solved it, but there's one problem left.
The cookie generated by nopCommerce contains the Customer GUID retrieved from the Customer Table. And the cookie generated by my application contains another GUID, so nopCommerce doesn't recognize. How do I manipulate the cookie generated by my app setting the GUID?

Thank you,

Allan
12 years ago
Ok,

Finally I solved it all.
Just copied part of the "SigIn" method from FormsAuthenticationService into my login method.

var now = DateTime.UtcNow.ToLocalTime();
                    //FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    var ticket = new FormsAuthenticationTicket(
                                        1 /*version*/,
                                        model.UserName,
                                        now,
                                        now.Add(new TimeSpan(2, 0, 0, 0)),
                                        true,
                                        model.UserName,
                                        FormsAuthentication.FormsCookiePath);

                    var encryptedTicket = FormsAuthentication.Encrypt(ticket);

                    var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                    cookie.HttpOnly = true;
                    cookie.Expires = now.Add(new TimeSpan(2,0,0,0));
                    cookie.Secure = FormsAuthentication.RequireSSL;
                    cookie.Path = FormsAuthentication.FormsCookiePath;
                    if (FormsAuthentication.CookieDomain != null)
                    {
                        cookie.Domain = FormsAuthentication.CookieDomain;
                    }

                    this.HttpContext.Response.Cookies.Add(cookie);
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.