mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-18 21:07:44 +03:00
Fix regular users not able to edit their info before logging in again
This commit is contained in:
parent
bc62efb059
commit
88f2fc35cd
@ -1,6 +1,7 @@
|
|||||||
import { fetchUtils } from 'react-admin'
|
import { fetchUtils } from 'react-admin'
|
||||||
import { baseUrl } from '../utils'
|
import { baseUrl } from '../utils'
|
||||||
import config from '../config'
|
import config from '../config'
|
||||||
|
import jwtDecode from 'jwt-decode'
|
||||||
|
|
||||||
const customAuthorizationHeader = 'X-ND-Authorization'
|
const customAuthorizationHeader = 'X-ND-Authorization'
|
||||||
|
|
||||||
@ -16,7 +17,9 @@ const httpClient = (url, options = {}) => {
|
|||||||
return fetchUtils.fetchJson(url, options).then((response) => {
|
return fetchUtils.fetchJson(url, options).then((response) => {
|
||||||
const token = response.headers.get(customAuthorizationHeader)
|
const token = response.headers.get(customAuthorizationHeader)
|
||||||
if (token) {
|
if (token) {
|
||||||
|
const decoded = jwtDecode(token)
|
||||||
localStorage.setItem('token', token)
|
localStorage.setItem('token', token)
|
||||||
|
localStorage.setItem('userId', decoded.uid)
|
||||||
// Avoid going to create admin dialog after logout/login without a refresh
|
// Avoid going to create admin dialog after logout/login without a refresh
|
||||||
config.firstTime = false
|
config.firstTime = false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user