techx / quill

📝 Registration, for hackathons!
https://medium.com/hackmit-stories/quill-an-open-source-hackathon-registration-system-91f3a06d22a2
GNU Affero General Public License v3.0
443 stars 341 forks source link

500 when trying to save application form #72

Closed lgg closed 6 years ago

lgg commented 6 years ago

Everything works fine Changed graduation years in

client/views/application/
server/models/User.js
and views and stats

run gulp server

Now can't save application form

PUT /api/users/SOMETOKENHERE/profile 500 171.183 ms - 66

I checked #1 but it seems that function https://github.com/techx/quill/issues/1#issuecomment-248448059 is already updated

jlin816 commented 6 years ago

What is the error output?

lgg commented 6 years ago

@jlin816 on server side in console:

PUT /api/users/SOMETOKENHERE/profile 500 171.183 ms - 66

On client side: Oops, something went wrong

lgg commented 6 years ago

Tried to reinstall npm modules - didn't help. I have made some localization for text, so on client side: image

On server side: image

lgg commented 6 years ago

Hmm, i even don't understand how i can debug it :/

lgg commented 6 years ago

Such user contains in MongoDB image

lgg commented 6 years ago

Shame on me :/

For others: check MongoDB schema and Users model.

I have this code in User.js:

schema.statics.validateProfile = function(profile, cb){
  return cb(!(
    profile.name.length > 0 &&
    profile.adult &&
    profile.school.length > 0 &&
    ['2018 2019 2020 2021 2022 2023 2024 2025'].indexOf(profile.graduationYear) > -1 &&
    ['M', 'F', 'O', 'N'].indexOf(profile.gender) > -1
    ));
};

But correct one is:

schema.statics.validateProfile = function(profile, cb){
  return cb(!(
    profile.name.length > 0 &&
    profile.adult &&
    profile.school.length > 0 &&
    ['2018', '2019', '2020', '2021', '2022', '2023', '2024', '2025'].indexOf(profile.graduationYear) > -1 &&
    ['M', 'F', 'O', 'N'].indexOf(profile.gender) > -1
    ));
};