Giter Site home page Giter Site logo

Comments (2)

pkmgarcia avatar pkmgarcia commented on May 22, 2024

Hey, I was also having this issue, but I found a way to get around it. The issue is with the value corresponding to "role" in the "user" object contained in the payload. This needs to be a role's "_id", not a role's "name". However, joi validates "role" by comparing it to role "name"s stored in the object constants["USER_ROLES"], which lies in /config.js. You will need to edit /config.js so that joi can compare "role" to role "_id"s instead of role "name"s which then allows the payload to pass role "_id"s.

Specifically, use the GET /roles endpoint to get a list of roles. Replace the values in constants["USER_ROLES"], found in /config.js, with the corresponding role "_id"s. Then whenever you give the payload, pass the role "_id" that corresponds to the role you wish to use.

from appy-backend.

JKHeadley avatar JKHeadley commented on May 22, 2024

Thanks for pointing this out! Also thank you @pkmgarcia for pointing out the workaround. Somehow this endpoint fell through the cracks during recent development. @vsiguero, if you pull the most recent code for the registration endpoint your payload should work. Although @pkmgarcia's work around is a viable option, I would suggest sticking with passing the role's "name" to the endpoint, simply because the use case of this endpoint assumes the user does not have an account, and therefore can not authenticate. In a working application the user would have to authenticate in order to pass a "GET" to the /roles endpoint, which would make it difficult to access the corresponding role "_Id".

from appy-backend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.