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

Add JWT authentication example #5463

Merged
merged 1 commit into from
May 25, 2020
Merged

Add JWT authentication example #5463

merged 1 commit into from
May 25, 2020

Conversation

dhmlau
Copy link
Member

@dhmlau dhmlau commented May 17, 2020

While working on #5421, I think it might be better to have an example app, so that the tutorial can point to the source code.

What's left: CLI, add this example to Examples.md, and CODEOWNERS file.

Related to: #5421

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@dhmlau dhmlau force-pushed the auth-example branch 3 times, most recently from e2d4f73 to 07b10e1 Compare May 21, 2020 01:36
Copy link
Contributor

@jannyHou jannyHou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhmlau The lint error is caused by local eslint plugin conflicts with the global one.
I solved it on local by:

  1. git clone a fresh lb-next repo
  2. remove the 4 dev dependencies I marked in the package.json file
  3. npm i to reinstall the dependencies, the package-lock.json file will also update
  4. then npm run lint:fix

I tried npm run start in the example repo but seems the app doesn't start, it's caused by the index.js file. It doesn't run the main function.

I updated my changes in branch https://github.com/strongloop/loopback-next/tree/jwt-example-update, feel free to merge it or use the code there. The app runs on my local and lint passes

@@ -0,0 +1,25 @@
Copyright (c) IBM Corp. 2018,2019.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: 2020

examples/todo-jwt/package.json Outdated Show resolved Hide resolved
examples/todo-jwt/package.json Outdated Show resolved Hide resolved
examples/todo-jwt/package.json Outdated Show resolved Hide resolved
examples/todo-jwt/package.json Outdated Show resolved Hide resolved
@dhmlau
Copy link
Member Author

dhmlau commented May 21, 2020

Thanks @jannyHou! I created this PR on your branch. #5509

type: 'string',
required: true,
})
password: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The password should have json property minLength: 8 as well to make sure the new user has valid password

Copy link
Contributor

@jannyHou jannyHou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍Tested on local the app works well, LGTM a few nitpicks.

examples/todo-jwt/README.md Outdated Show resolved Hide resolved
@dhmlau dhmlau merged commit 1abb37b into master May 25, 2020
@dhmlau dhmlau deleted the auth-example branch May 25, 2020 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants