Skip to content

Instantly share code, notes, and snippets.

@marshallswain
Created May 17, 2018 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshallswain/9e4ceda7b3f839065f009d702cde290b to your computer and use it in GitHub Desktop.
Save marshallswain/9e4ceda7b3f839065f009d702cde290b to your computer and use it in GitHub Desktop.
Next.js Feathers auth trick
jwtAuth({ token }) {
if (!isClient) {
app().set('accessToken', token);
return this.verifyToken(token)
.then(payload => this.loadUser(payload.userId));
}
return app()
.authenticate({ strategy: 'jwt', accessToken: token })
.then(response => this.verifyToken(response.accessToken))
.then(payload => this.loadUser(payload.userId));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment