earmuff-jam / climate

Climate is designed to aide you with your item management.
https://climate-theta.vercel.app/
0 stars 0 forks source link

Introduce Roles and Roles History Table within Profiles Table #66

Closed earmuff-jam closed 1 year ago

earmuff-jam commented 1 year ago

Introduce roles table to determine the user type. If the user is an owner of a property he should see the property related pages. If he is the tenant he should see tenant related pages. if he is both he should be able to see both. there is a possibility of such scenarios ( in duplex ). The assumed workflow -

  1. when a property owner adds a new tenant - the tenant email address is used to send a link to request the user to sign up.
  2. create a trigger that allows the newly created tenant to be a user in the profiles table. however he / she would not have the "selected_role" in it. AN EMPTY "SELECTED_ROLE" would mean that the user is is "PENDING" state.
  3. when the user sign's up and ( if there is a matching email - this is the key ). the matching email is what supabase auth uses. ( IS IT THE SAME FOR OTHER LOG IN AS WELL ) ??
  4. we should have already support for the ability to add more login methods. - THIS TICKET IS BLOCKED until this is resolved.
  5. when we find a matching email , but empty "selected_role" or "property" or "tenant" -><- we should realize that this is the tenant. @sujan-dahal what else can we think of to make use of.
  6. we should then immediately assign role "TENANT" to this user. THIS SHOULD BE THE ONLY WAY FOR A TENANT TO GAIN ACCESS TO THE APP. by default only property owners can auto log in ONLY FOR NOW.
  7. this should provision tenant mode.
  8. what if a user is both property owner and tenant ? @sujan-dahal asked.
  9. if there is both values valid scenario then we would want to - -- allow the user to choose between what view mode they would want to see. this is the "SELECTED_ROLE" idea. Can this get us somewhere ? @sujan-dahal said and we agreed. Totally legit.
earmuff-jam commented 1 year ago

we should not do the login with other methods approach.

mohit2530 commented 1 year ago

An approach that is being worked on at the moment is that the profiles table updates as the properties are added and removed. As this happen we grant proper roles based on the user type.

mohit2530 commented 1 year ago

Flowcharts are created.