Skip to content

Properties won't override while extending from User model. #2125

Closed

Description

@gothammm

I'm trying to extend from User model.

 "properties": {
      "id": {
      "type": "string",
      "id": true,
      "required": true,
      "defaultFn": "uuid"
    },
    "email": {
        "type": "email",
        "required": false
     },
    "countryId": {
      "type": "string",
      "required": true
    }
 }

So, email required false, does not make any change at all, I still get validation error saying email is null.

Any idea how to override properties?

Activity

  1. richardpringle commented on Mar 7, 2016

    @richardpringle
    Contributor

    @peek4y, it's not that the property isn't overridden, it's that any sub class of the User class still performs validation on email regardless. Is there any particular reason you don't want to include email?

    It might almost be easier to build your own "user" model rather than extend the existing one. For now, I will throw a feature label on this issue.

    Sorry I couldn't be more helpful!

  2. gothammm commented on Mar 7, 2016

    @gothammm
    Author

    Ok thanks for the explanation.

    Well, all i need is mobile number for validation sometimes and I really dont need the email.

  3. richardpringle commented on Mar 15, 2016

    @richardpringle
    Contributor

    @peek4y, go down to the verify email section on this page to see how to turn email verification off. It's a part of the options parameter of your user model in the model-config.json config file.

  4. gothammm commented on Mar 16, 2016

    @gothammm
    Author

    So, this should skip email validation during sign up right?

    Sorry, din't get time to try it out.

  5. richardpringle commented on Mar 16, 2016

    @richardpringle
    Contributor

    Yeah it should. I actually haven't had time to try it out either to be honest... Let me know how it goes

  6. gothammm commented on Mar 16, 2016

    @gothammm
    Author

    Nope, it doesn't work 😢

    "message": "The userinstance is not valid. Details:emailcan't be blank (value: undefined);email is null (value: undefined)."

  7. richardpringle commented on Mar 16, 2016

    @richardpringle
    Contributor

    Definitely a bug then, I'll take a look

  8. gothammm commented on Mar 16, 2016

    @gothammm
    Author

    👍 Thanks!

  9. richardpringle commented on Mar 16, 2016

    @richardpringle
    Contributor

    @peek4y, sorry that was silly of me. That is for verifying not VALIDATING**. The built-in User model actually depends on email for some of its functionality so it doesn't really make sense to be able to remove it.

    Instead, you can take a look at the User model code and copy some of its functionality for your own model.
    https://github.com/strongloop/loopback/blob/master/common/models/user.js
    https://github.com/strongloop/loopback/blob/master/common/models/user.json

  10. gothammm commented on Mar 17, 2016

    @gothammm
    Author

    Hmm, that doesn't sound right to me. I was wondering if there could be a simpler way to solve this.

  11. richardpringle commented on Mar 17, 2016

    @richardpringle
    Contributor

    I mean a workaround would be to insert a dummy email but currently, we do not support extending the user model without an email at all. I have left a feature tag on this issue so that we could potentially disable the email validation, but realistically, this isn't in high demand (not to say that is wouldn't be useful in certain cases).

    In your case, you could extend or use the built-in user model and get your user to provide their email upon registration. From there, you do not need to use an email address to login.

  12. gothammm commented on Mar 18, 2016

    @gothammm
    Author

    Got it 👍 will go with a workaround. Hoping to see this feature soon 😄

  13. Emiya0306 commented on Jun 12, 2016

    @Emiya0306

    @richardpringle @peek4y I think it is a good feature that can select special fields to do login. Make it more flexible and more powerful! 👍

  14. 8 remaining items

  15. stale commented on Nov 11, 2017

    @stale

    This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

  16. Vandivier commented on Jan 6, 2018

    @Vandivier

    Does stalebot reopen? Is the Loopback 3 team open to a pull request on this issue?

  17. richardpringle commented on Jan 7, 2018

    @richardpringle
    Contributor

    @kjdelisle ^

    @Vandivier, I'm sure the LoopBack team is always open to pull requests!

  18. richardpringle commented on Jan 7, 2018

    @richardpringle
    Contributor

    FYI, I'm no longer on the LB team... just thought I would make that clear

  19. ali1tokan commented on Feb 8, 2018

    @ali1tokan

    in case of we made a model like user on our own can we use the access token built in... and if so do we have to persist it to the data source for example mysql like that model we made.... or keep it in the memory..

  20. kjdelisle commented on Feb 8, 2018

    @kjdelisle
    Contributor

    Pull requests welcome!

    Though, I would say that you'd probably be better off suggesting this as a part of the next major version of loopback: https://github.com/strongloop/loopback-next

    We're looking for more community contributors, and since we're still in alpha, there's plenty of room for change!

  21. stale commented on Apr 9, 2018

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  22. stale commented on Apr 23, 2018

    @stale

    This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions