Code Monkey home page Code Monkey logo

node-mysql's Introduction

Токен Для защищенной зоны используется middlewares/checkAuth.js

const token = req.header('x-auth')

При успешной проверке выдается новый токен (с тем же ID пользователя)

res.header('x-auth', newToken);

Стоп-лист После выхода через "logout" идентификатор id пользователя (email или телефон) попадает в стоп-лист на 11 минут (время жизни токена 10 минут). Стоп-лист организован с помощью модуля 'node-persist' следующим образом:

  1. Стоп-лист хранит состояние после перезагрузки сервера. В рабочей версии, наверное, лучше использовать Redis.
  2. Стоп-лист автоматически обнуляет значения, которым более 11 минут. То есть когда гарантированно истекают выданные с этим id токены.
  3. После успешного signIn id пользователя удаляется из стоп-листа.

Инициализация стоп-листа в server.js

const blackList = require('node-persist'); blackList.init( {dir: 'app/black-list', ttl: 11 * 60 * 1000});//11 минут

Дамп MySql

test_users.sql в корневой папке

Структура базы

База содержит 1 таблицу users с двумя полями id и password.

node-mysql's People

Contributors

yinfo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.