how to get the user_id that in jwt to fill into a column? #9482
-
example. when update the table rows , i want to put the user_id(in jwt) to 'update_user_id' how can i do? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @lwsbox If I am guessing correct, you are using JWT authentication mode here. I this case, we believe that your auth server generates JWT which upon decoded, contains user_id in it. For updating table row, you'll need to perform update mutation to that table. ̦ Preferred way would be to pass user_id as one of the session variables, say for eg. We can utilize "column presets" functionality where column value gets updated from the session variable everytime when update mutation is performed against that specific table. You can set column preset for any column in permissions and select the preset type (either static value or session variable). More demonstration here - https://hasura.io/docs/latest/schema/postgres/default-values/column-presets/#introduction Does this address your concern ? Do let us know, thanks ! |
Beta Was this translation helpful? Give feedback.
Hey @lwsbox
If I am guessing correct, you are using JWT authentication mode here. I this case, we believe that your auth server generates JWT which upon decoded, contains user_id in it.
For updating table row, you'll need to perform update mutation to that table. ̦ Preferred way would be to pass user_id as one of the session variables, say for eg.
x-hasura-user-id
.We can utilize "column presets" functionality where column value gets updated from the session variable everytime when update mutation is performed against that specific table. You can set column preset for any column in permissions and select the preset type (either static value or session variable). More demonstration here - h…