1

I would like to create a DefaultPrinterId property (field) attached on UserAuth table. This DefaultPrinterId field is a foreign key on a Printer.Id field (Printer is a custom table).

My question is, What is the best way to create a new field for UserAuth and fill property value after authentication? Should I override AuthUserSession, UserAuth, OrmLiteAuthRepository?

I am a bit confused, even after reading documentation.

Thanks.

labilbe
  • 3,501
  • 2
  • 29
  • 34

1 Answers1

1

You'd typically want to leave the UserAuth table fixed and instead use the recommended approach for extending UserAuth is using the extension points available but you are also able to extend the UserAuth tables for by inheriting your CustomUserAuth table from UserAuth and then instead of using OrmLiteAuthRepository, create a custom MyOrmLiteAuthRepository AuthProvider specifying the custom UserAuth and UserAuthDetails tables you want to use instead, e.g:

public class MyOrmLiteAuthRepository 
  : OrmLiteAuthRepository<CustomUserAuth, UserAuthDetails>
{
    public OrmLiteAuthRepository(IDbConnectionFactory dbFactory) : base(dbFactory) {}

    public OrmLiteAuthRepository(IDbConnectionFactory dbFactory, string namedConnection=null) 
      : base(dbFactory, namedConnection) {}
}
Community
  • 1
  • 1
mythz
  • 141,670
  • 29
  • 246
  • 390