Skip to content
Reusable utility methods for GraphQL authentication in Node.js
Branch: master
Clone or download
Latest commit f5b9f24 May 29, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
src initial commit May 27, 2019
.gitignore initial commit May 27, 2019 Update May 29, 2019
package.json fix readme, bump version May 27, 2019
tsconfig.json initial commit May 27, 2019
yarn.lock initial commit May 27, 2019

👩‍✈️ graphql-user

This package is using the packages bcrypt and jsonwebtoken in order to provide some reusable functions for GraphQL authentication.

🙋‍♂️ Made by @thekitze

Other projects:

  • 🏫 React Academy - Interactive React and GraphQL workshops
  • 💌 Twizzy - A standalone app for Twitter DM
  • 💻 Sizzy - A tool for testing responsive design on multiple devices at once
  • 🤖 JSUI - A powerful UI toolkit for managing JavaScript apps
  • 🎥 Vlog - My YouTube channel

Make sure that your app has an APP_SECRET env variable.

It includes the following functions:

  • getUserId(context): string - Returns the id from the currently logged-in user context.request.get("Authorization")
  • getToken(userId: string): string - Returns a token by signing an object containing {userId} using the APP_SECRET
  • getHashedPassword(password: string): string - Returns a hashed version of a password
  • comparePassword(password: string, comparePassword:string): boolean - Compares a password and a hashed password
You can’t perform that action at this time.