Как стать автором
Обновить
6
0
Babichev Oleg @obabichev

Пользователь

Отправить сообщение

React Token Auth

Время на прочтение 10 мин
Количество просмотров 44K


Problem


Authorization is one of the first problems developers face upon starting a new project. And one of the most common types of authorization (from my experience) is the token-based authorization (usually using JWT).


From my perspective, this article looks like "what I wanted to read two weeks ago". My goal was to write minimalistic and reusable code with a clean and straightforward interface. I had the next requirements for my implementation of the auth management:


  • Tokens should be stored in local storage
  • Tokens should be restored on page reload
  • Access token should be passed in the network requests
  • After expiration access token should be updated by refresh token if the last one is presented
  • React components should have access to the auth information to render appropriate UI
  • The solution should be made with pure React (without Redux, thunk, etc..)
Read more →
Всего голосов 6: ↑4 и ↓2 +2
Комментарии 22

Информация

В рейтинге
5 078-й
Зарегистрирован
Активность