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
[Bug?]: dbAuth userAttributes
comment error
#10456
Comments
@pantheredeye I'm meeting with @dthyresson later today, I'll ask him about the |
@pantheredeye The redwood/packages/auth-providers/dbAuth/setup/src/templates/api/functions/auth.ts.template Line 132 in 852e457
The templates sets it as In you case, just change the argument to be without the underscore and then in the user create data refer to the variable as |
That all makes sense and is easy enough. I was really hoping that we could make a note of sorts to inform the user how to handle this by either adding the |
How do we close this? I do feel like this will trip someone else up, so I would like to have a note in the docs explaining this. If that is a no vote, then we can just close this issue, correct? |
If anything I’d update the template to:
I do think the ide and typescript give rather informative messaging to let the developer implement correctly |
I think that in many cases we already have too many and too long comments in the generated code. At some point people will just not read it because it's too much. I also don't like the idea of disabling the linting rule. You really shouldn't have unused variables littering your code. And we also don't want to generate code with red squiggles. It's a difficult balance 🙂 As @pantheredeye found out, using underscores, like in I don't think we should add a comment in the code at every place we use the underscore for unused variables. |
Tobbe's suggestion seems fine. Although, I question who would read a document like that before running into an error like this. It would be great if we could somehow introduce the message into the IDE error messaging. At this point it feels like since no one has brought this up before, most people probably understand it. But, from my perspective, as a dev who is not confident in the intricacies of the framework, it is scary when I run into an "error" inside of an auth package while essentially following the instructions and uncommenting I actually googled the underscore before making the issue to see if I could figure it out. Even after my search, I did not understand that the underscore indicated an unused value. I was afraid that removing the underscore might make my code interfere with framework code somewhere else. The "ide and typescript give rather informative messaging to let the developer implement correctly". The IDE's messaging was |
What's not working?
After setting up dbAuth, the signupOptions code in
api\src\functions\auth.js
has an example user attribute that is commented out. Well, I needed that exact field, so I uncommented it and ran into an error on the next signup attempt. I ended up adding an underscore to match the props in the handler, changing it fromname: userAttributes.name
toname: _userAttributes.name
and sign up worked.I am not sure what the _ indicates, but it is in the params for the handler, so I am guessing it should be included the commented out line?
This search: https://github.com/search?q=repo%3Aredwoodjs%2Fredwood%20userAttributes.name&type=code has quite a few files show up... if its a matter of going through most of these and adding _, could we label this "Good first Issue?"
Generated Code:
Working code with accompanying paragraph at the top:
The text was updated successfully, but these errors were encountered: