How to add user to my own database after supabase creates new users - supabase

I am new to supabase. When a new user signs in or signs up in supabase, I want to add the user to my own database.
I've tried creating a public.users supabase database using triggers when a new user joined. And created a database function on the updation of public.users database to hit an endpoint, creating a user in my database. This looks complicated. Are there any other ways to simplify this process?

Related

AWS Amplify Graphql Creating a new User table, necessary?

I'm fairly new to Amplify and been playing around with it for a couple of weeks now. I've been incorporating it into Next.js, which is pretty nice.
I originally created a new User table/record using lambda function: after a user signs up and confirms their email, it should automatically create a new record in the User table with some information. I only did this because I thought Amplify only provided a few attributes, but until recently I found out that you can pretty much create custom attributes.
So, because of this, would there be an argument to create another User table? I would like to know how people are handling User information in big applications.
I guess one thing I can think of is making relationships with other tables. I haven't gone too far into figuring this out, but is it possible to still make connections if I don't have User table in my graphql schema?
Yes I have the same issue and was thinking to have a Users table where I enable owner authorization. This Owner-based authorization allows you to tie a data record to a user. Owners can read, create, update, and delete the record.
Allow the owner to perform these operations on their own records:
Create
Read
Update
Delete

Flyway: Oracle create user conflicts with another user though user does not exist in the first place

Flyway 7.7.3
I created a couple of repeatable migrations sql like below:
R__create_role.sql
-- Create role
CREATE ROLE ${roleName};
-- Grant privileges to role
GRANT SELECT ON ${tableName} TO ${roleName};
R__create_user.sql
-- Create user
CREATE USER ${newUser} IDENTIFIED BY ${userPwd};
-- Grant role to user
GRANT ${roleName} to ${newUser};
When I run flyway...migrate on this with supplied new user, I get below
CREATE USER TEST_USER_3 IDENTIFIED BY test3, Error Msg = ORA-01920: user name 'TEST_USER_3'
conflicts with another user or role name
BUT, the new user is created anyway.
NOTE1: I did make sure that TEST_USER_3 is not in the database before I run flyway...migrate. Also, I tried adding WHENEVER SQLERROR CONTINUE; after CREATE USER ${newUser} IDENTIFIED BY ${userPwd}; (because i know it creates the new user anyway), but I still get the error message.
NOTE2: I did the same thing in postgres (repeatable migrations for create role and user) and it works just fine.
Is there something wrong with the way I set up the queries ? or is this an issue with flyway-oracle? and is there a solution to this ?

Tracking records created by different users of a multi user application in Laravel 6

i am working on a multi user application where i have two tables for authentication, admins table and users table.
currently when a user registers, their information gets saved in the admins
table(which automatically makes them admins for the registered account) and are authenticated using the same table.
These admins can create other users and assign roles and permisions to restrict them from accessing certain information associated with that account.
These users are saved in the users table with admin_id to track which account they belong to,they are authenticated using the same users table.
Now my issue is how to track all records created by all these different users of the account.
For instance when and admin creates a post, the admin_id will be used to track the post and when a user creates a post the user_id will be used to track the post and with the help of a hasManyThrough relationship between the Admin,User and Post models all posts associated with the account can be obtained and displayed to the admin.
But for a case where a user is given the permision to view all posts associated with the account i do not know how this is going to work.
Initially, what i wanted to do to avoid all these confusion was, during authentication,i would just get the id (if admins table is being used for auth) or admin_id (if users table is being used) and store as account_id in localstorage or session.
This way, account_id will be the same for all the different users of the account and posts created by an admin of an account will be tracked with the same id as posts created by different users of the same account.
So is this approach good enough?
Is there a better approach to this problem?
and finally is this a dumb question?
Help me out guys!
Thanks in advance.

row level security and check duplicate

I create an application with spring boot and Postgresql. I use Row Level Security of posgresql to "secure/limit" the data of connected user.
(I use JdbcInterceptor to add "set role" on each session and "reset role" after)
My problem:
I want to check duplicate before insert and duplicate can be on data which user cannot see.
For exemple, user can only access to his email, he can create a new email, but before create, if want to check if email doesn't exist in the database.
Do you have an idea how i can do that?

Prevent multiple login from a user in the same session

How to prevent multiple login from a user in the same session in Wicket?
you can create a table in your database to hold the ids of logged in users.
when a user logs in check if his id is in said table
otherwise insert his id into that table.
you also need to remove the user's id from the table once user logs out
you can integrate spring security with wicket. Spring security handles it automatically.

Resources