I’ve created a CustomAuthUserSession with a custom field:
public class CustomAuthUserSession : AuthUserSession
{
public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary<string, string> authInfo)
{
base.OnAuthenticated(authService, session, tokens, authInfo);
var customSession = session as CustomAuthUserSession; // AgencyId == 1 right here, yay!
if (customSession == null)
return;
}
public int AgencyId { get; set; }
}
In my CustomAuthProvider I set the agency Id in the OnAuthenticated method:
(session as CustomAuthUserSession).AgencyId = user.AgencyId; // AgencyId = 1 (set AgencyId)
In my service (MeService), AgencyId is 0:
public class MeService : Service
{
public GetMeResponse Get(GetMe request)
{
var session = this.GetSession() as CustomAuthUserSession;
return new GetMeResponse()
{
Email = session.Email,
FirstName = session.FirstName,
LastName = session.LastName,
Roles = session.Roles,
Permissions = session.Permissions,
AgencyId = session.AgencyId // This is 0?!
};
}
}
Why is AgencyId 0 when I call the MeService to pull the users information?
I can even see in the CacheEntry table in the DB that AgencyId is 1.