mitodl / micromasters

Portal for learners and course teams to access MITx Micromasters® programs
https://mm.mit.edu
BSD 3-Clause "New" or "Revised" License
29 stars 17 forks source link

Don't validate profile on every page load #2380

Open pdpinch opened 7 years ago

pdpinch commented 7 years ago

Currently, we validate all the fields in the user profile whenever the MicroMasters app is loaded (e.g. /dashboard, /learner or /learners). This seems unnecessary, especially when we have a field filled_out which is supposed to be true when the user's profile is complete.

For this to work, when we add new required fields to the profile model, we have to include a migration that sets filled_out to false for any user that doesn't have a value for the new required field.

acceptance criteria

pdpinch commented 7 years ago

@Ferdi is this accurate to what we discussed this morning?

@aliceriot does this make sense?

alicewriteswrongs commented 7 years ago

It generally makes sense to me, but I'm not sure I agree with the plan overall. I don't see a great problem with doing validation on the frontend when we load the app - it is not an expensive operation or anything. We already have a system in place for identifying when the user has missing fields and prompting them to be filled in, I don't really see why we would spend time and effort to remove that feature from the frontend and move it to the backend.

BTW the redirect code currently checks both filled_out and the validation, doing something like:

// this runs the full validation suite, returns a boolean
let [ complete ] = validationProfileComplete(profile);

if ( ! complete || ! profile.filled_out ) {
  router.push(`/profile`) // do the redirect
}
alicewriteswrongs commented 7 years ago

Also, to hopefully clarify a little, filled_out captures a different thing than that the validation passes - filled_out could be false on a valid profile, because we do not set filled_out to be true until the user gets all the way through the profile flow. So they could fill out the first page, after which their profile would pass the validation, but filled_out would still be false.