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

Missing field 'roles' in auth.ts during tutorial #5542

Closed
Avataw opened this issue May 15, 2022 · 2 comments
Closed

Missing field 'roles' in auth.ts during tutorial #5542

Avataw opened this issue May 15, 2022 · 2 comments

Comments

@Avataw
Copy link
Contributor

Avataw commented May 15, 2022

During the tutorial chapter 4 / Authentication, I've noticed that in the auth.ts I get some errors:

image

Makes sense as I was not supposed to add roles to the user in the model

model User {
  id                  Int       @id @default(autoincrement())
  name                String?
  email               String    @unique
  hashedPassword      String
  salt                String
  resetToken          String?
  resetTokenExpiresAt DateTime?
}

nor in the select of getCurrentUser in auth.ts

export const getCurrentUser = async (session) => {
  return await db.user.findUnique({
    where: { id: session.id },
    select: { id: true, email: true },
  })
}

The tutorial does mention (see "AUTHENTICATION VS. AUTHORIZATION" infobox) above that Authorization is going to come up later - still I think that stumbling upon errors while doing the tutorial can be confusing or distracting to new users.

I'd propose the following options:
A) Address the missing roles in auth.ts with a warning and mention that it's going to come later in the tutorial
B) add roles to the model already and leave it empty with a comment that it's going to be correctly implemented later

@jtoar jtoar moved this to Triage in Main May 15, 2022
@jtoar jtoar added this to Main May 15, 2022
@simoncrypta
Copy link
Collaborator

Hi @Avataw,

Option A) is a great idea!
I think the best way to do it is to write a comment in TS version of the code exemple where the error show up.

Feel free to open a PR if you want !
https://github.com/redwoodjs/redwood/blob/main/docs/docs/tutorial/chapter4/authentication.md

@simoncrypta simoncrypta moved this from Triage to Backlog in Main May 17, 2022
@simoncrypta simoncrypta removed their assignment May 17, 2022
@Avataw
Copy link
Contributor Author

Avataw commented May 18, 2022

I'll take care of it, feel free to assign me :)

@Avataw Avataw closed this as completed Jun 4, 2022
Repository owner moved this from Backlog to Done in Main Jun 4, 2022
@redwoodjs-bot redwoodjs-bot bot moved this from Done to Archived in Main Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Archived
Development

No branches or pull requests

2 participants