Before I go to bed, I think I got it:
after auth, and just before the first SlidingSession.Execute() call runs the req.SaveSession() command, my db cache entry looks like this:
{__type:"api.services.infrastructure.CustomUserSession, api.services",activeStaffId:00000000000000000000000000000000,id:xveZlAopBDMEFufOXjSV,userAuthId:92,userAuthName:host,userName:host,firstName:HostCompany,lastName:Administrator,email:Host.Company@HostCompany.com,fullName:HostCompany Administrator,createdAt:"2019-06-24T20:44:34Z",lastModified:"2019-06-24T20:44:34Z",roles:[],permissions:[],isAuthenticated:True,fromToken:False,tag:0,authProvider:credentials,providerOAuthAccess:[]}
but AFTER the record saves in the db, it looks like this:
{__type:"api.services.infrastructure.CustomUserSession, api.services",activeStaffId:00000000000000000000000000000000,id:xveZlAopBDMEFufOXjSV,userAuthId:92,userAuthName:host,userName:host,firstName:HostCompany,lastName:Administrator,email:Host.Company@Host
Note that I’ve lost all the IsAuth etc properties from the serialised session. I use the out-of-the-box CredentialsAuthProvider but I DO have a CustomUserSession, which currently actually doesn’t add any functionality.
On closer inspection, it seems that the issue is possibly related somehow to an OrmLiteConfig setting that I use, whereby:
// Configure string handling defaults for ormlite
var converter = OrmLiteConfig.DialectProvider.GetStringConverter();
converter.UseUnicode = true; // We are multicultural
// Override default string length to use 255 characters instead of default VARCHAR(MAX) setting
converter.StringLength = 255;
seems to trunctate my saved session data at 255 characters, effectively logging me out. Not sure if thats by design, or a bug in the cache? I wasn’t expecting the converter.StringLength to prevent saving longer strings, I only meant to save myself from having to set all strings in the DB creation phase from being nvarchar(max) by default.