Integrate new table schema created using plugin with authentication

Hello, I have created new table schema using plugin, and now I would like to integrate and populate that table during authentication. It might be the cas that I haven't seen required documentation on that, so link to that could also help. Basically I have this TermsOfService table plugin:
const tosPlugin = () => {
return {
id: 'tos-plugin',
schema: {
TermsOfService: {
fields: {
...
const tosPlugin = () => {
return {
id: 'tos-plugin',
schema: {
TermsOfService: {
fields: {
...
and I have inserted this plugin in config:
export const auth = betterAuth({
...
plugins: [tosPlugin(), privacyPolicyPlugin()],
});
export const auth = betterAuth({
...
plugins: [tosPlugin(), privacyPolicyPlugin()],
});
Should I create hook for populating that table? If so should I create connection myself, or is there a way to do this using better-auth. Thanks!
5 Replies
lonelyplanet
lonelyplanet2mo ago
Just use hooks!, after signin add a Row in the Database, im not to sure how you have set it up but i believe you can add hooks inside the plugin itselft
Augustas Paliulis
Augustas PaliulisOP2mo ago
Yeah you can add these values manually, but I though it is possible to actuall use auth flow, upload those values using better-auth and not seperate connection to db. Since then what js ghe reason for adding new table schema using plugin
lonelyplanet
lonelyplanet2mo ago
So you want to have a custom table? That when a user signs up it adds a custom row to this custom table but not use DB? Better auth adapter has fixed methods of updating users you will need to use a db connection yourself even if you use the internaladapter it wont have a function to do this
Augustas Paliulis
Augustas PaliulisOP2mo ago
Yeah that was my idea But I guess I will change this architecture little bit Thanks for clarification

Did you find this page helpful?