Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Profile Image on Sign Up #85

Open
youralien opened this issue Aug 24, 2018 · 0 comments
Open

Require Profile Image on Sign Up #85

youralien opened this issue Aug 24, 2018 · 0 comments
Labels

Comments

@youralien
Copy link
Member

youralien commented Aug 24, 2018

I was struggling with this... so here is a list of things to try for the next time someone tries to fix this issue.

Starting documentation on configuring fields in AccountsTemplates
https://github.com/meteor-useraccounts/core/blob/master/Guide.md#form-fields-configuration

In accounts_config.js

AccountsTemplates.addField({
  _id: 'profileImage',
  type: 'text',
  displayName: 'Profile photo',
  template: 'profileImageUpload',
  // the field value is not set based on profile image upload
  // 1. To see where the validate gets called, @see https://github.com/meteor-useraccounts/core/blob/2e8986813b51f321f908d2f6211f6f81f76cd627/lib/templates_helpers/at_input.js#L98
  // 2. Definition of validate where parameter "value" is passed @see https://github.com/meteor-useraccounts/core/blob/2e8986813b51f321f908d2f6211f6f81f76cd627/lib/field.js#L224
  required: true,
  // somehow, it is hard to enter this func call. Maybe because the "value" is not even set for it to pass the required check
  // @see https://github.com/meteor-useraccounts/core/blob/2e8986813b51f321f908d2f6211f6f81f76cd627/lib/field.js#L274
  func: function(value) {
    let imageFiles = getImageFiles();
    let photoUploaded = imageFiles.length > 0;
    if (photoUploaded) {
      this.setSuccess();
      this.setValidating(false);
      return false;
    } else {
      this.setError(AccountsTemplates.texts.requiredField);
      this.setValidating(false);
      return AccountsTemplates.texts.requiredField
    }
  },
  errStr: 'Profile Image Required'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant