w3tecch / express-typescript-boilerplate

A delightful way to building a RESTful API with NodeJs & TypeScript by @w3tecch
MIT License
3.29k stars 904 forks source link

Implementing Auth0 #87

Closed tlays11 closed 6 years ago

tlays11 commented 6 years ago

Real useful project. Thanks for making it open. I was trying to figure out how to swap out the mock Auth0 server with a real Auth0 account. Do you have any guides here?

dweber019 commented 6 years ago

@tlays11 actually you have to replace the implementation of these method https://github.com/w3tecch/express-typescript-boilerplate/blob/develop/src/auth/AuthService.ts#L34 with the following request https://auth0.com/docs/api/authentication#user-profile.

Things to change:

Additionally you have to change this line https://github.com/w3tecch/express-typescript-boilerplate/blob/develop/src/auth/currentUserChecker.ts#L19 to use the auth0 email in the where clause or you extend the user model to have a auth0 id field.

Probably you also like to change https://github.com/w3tecch/express-typescript-boilerplate/blob/develop/src/auth/TokenInfoInterface.ts as you get more information from auth0, but that's up to you ;)