Users "Setup for company" field is overridden to true for existing users during subscription purchase
Users "Setup for company" field is overridden to true for existing users during subscription purchase.
In the subscription store, we override the isSetupForCompany
for existing users.
isSetupForCompany: parseBoolean(setupForCompany) || !isNewUser,
So if a user has a nil
or false
ruby setup_for_company
, ruby converts it to false
. The above logic, makes it true.
Finally in the subscriptions controller#create (API) we update the user, overriding the setup_for_company
to true
.
current_user.update(setup_for_company: true) if params[:setup_for_company]
Related MR !25124 (merged)
Suggested Modification 1
Remove the || !isNewUser
.
isSetupForCompany: parseBoolean(setupForCompany),
- But is
isSetupForCompany
used for some frontend logic? - What to do for older users who have
null
/nil
in that field?
- ref Nullish coalesce
Suggested Modification 2
We may remove controller logic in subscriptions controller#create (API) where we update the user, overriding the setup_for_company
to true
at least for existing users.
Edited by Alper Akgun