I have 2 AppHost run in different subdomain
- First: id.example.com, SessionFeature is turn on.
- Second: api.example.com, AuthFeature is turn on.
In view of first app, i have form with submit authenticate with api
form action = api.example.com/api/auth/credentials
When authenticated then i save customer info into session in custom credentials provider like this
public override IHttpResult OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary<string, string> authInfo)
{
base.OnAuthenticated(authService, session, tokens, authInfo);
var customUserAuthSession = (CustomUserSession)session;
try
{
using (var uvc = authService.ResolveService<UserService>())
{
var customer = uvc.GetCustomerByEmail(session.UserAuthName);
if (customer != null)
{
customUserAuthSession.UserAuthId = Convert.ToString(customer.UserId);
customUserAuthSession.UserName = customer.PrimaryEmail;
//customUserAuthSession.UserAuthName = user.CustomerName;
customUserAuthSession.DisplayName = customer.FullName;
customUserAuthSession.Email = customer.PrimaryEmail;
customUserAuthSession.Address = customer.Address;
customUserAuthSession.PhoneNumber = customer.PrimaryPhone;
customUserAuthSession.CustomerId = Convert.ToInt32(customer.Id);
customUserAuthSession.SecurityNumber = customer.SN;
customUserAuthSession.ProvinceId = customer.ProvinceId;
customUserAuthSession.CityId = customer.CityId;
customUserAuthSession.Roles = new List<string>()
{
"Customer"
};
authService.SaveSession(customUserAuthSession, SessionExpiry);
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return null;
//return base.OnAuthenticated(authService, customUserAuthSession, tokens, authInfo);
}
Login and get session with customer info working right.
BUT SOMETIME customer info is wrong? It’s get another customer info in our system.
I think will be session id is wrong.
Any idea here, please help.