Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/will123195/express-user-auth

Simple User Registration and Login for your Express app
https://github.com/will123195/express-user-auth

Last synced: 3 days ago
JSON representation

Simple User Registration and Login for your Express app

Awesome Lists containing this project

README

        

# express-user-auth

Quickly add user authentication to your Express app

- Works with any database
- Password hash stored using bcrypt
- Password reset functionality
- TODO: Login with Facebook, Twitter, Google, or Github

## Install

```
npm i express express-user-auth
```

## Requirements

Your `createUser` and `updateUser` methods must be able to save the following fields:
- `passwordHash`
- `passwordAlgo`
- `passwordResetToken`

## Usage

```js
import express from 'express'
import auth from 'express-user-auth'

const app = express()

// all functions are async and should return a Promise
app.use('/', auth({
sessionSecret: 'XXXX',
jwtSecret: 'XXXX',
createUser: function (user) { return user },
getUserByUsername: function (username) { return user },
updateUser: function (data) { return user },
sendPasswordReset: function ({ user, uri }) { },
passwordResetRedirectURL: '/'
}))

app.listen(3000)
```

## Routes

`express-user-auth` creates the following routes:

- `GET /register`
- `GET /login`
- `GET /forgot-password`
- `GET /reset-password`

- `POST /register`
- `POST /login`
- `POST /send-password-reset`
- `POST /reset-password`

## Screenshots

You get this UI out of the box: