Remove unused localStorage config
This commit is contained in:
+46
-62
@@ -26,70 +26,54 @@ const i18nProvider = polyglotI18nProvider(
|
|||||||
|
|
||||||
const history = createHashHistory()
|
const history = createHashHistory()
|
||||||
|
|
||||||
const App = () => {
|
const App = () => (
|
||||||
try {
|
<Provider
|
||||||
const appConfig = JSON.parse(window.__APP_CONFIG__)
|
store={createAdminStore({
|
||||||
|
authProvider,
|
||||||
// This flags to the login process that it should create the first account instead
|
dataProvider,
|
||||||
if (appConfig.firstTime) {
|
history,
|
||||||
localStorage.setItem('initialAccountCreation', 'true')
|
customReducers: {
|
||||||
}
|
queue: playQueueReducer,
|
||||||
localStorage.setItem('baseURL', appConfig.baseURL)
|
albumView: albumViewReducer,
|
||||||
} catch (e) {}
|
theme: themeReducer
|
||||||
|
}
|
||||||
return (
|
})}
|
||||||
<Provider
|
>
|
||||||
store={createAdminStore({
|
<Admin
|
||||||
authProvider,
|
dataProvider={dataProvider}
|
||||||
dataProvider,
|
authProvider={authProvider}
|
||||||
history,
|
i18nProvider={i18nProvider}
|
||||||
customReducers: {
|
customRoutes={customRoutes}
|
||||||
queue: playQueueReducer,
|
history={history}
|
||||||
albumView: albumViewReducer,
|
layout={Layout}
|
||||||
theme: themeReducer
|
loginPage={Login}
|
||||||
}
|
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
<Admin
|
{(permissions) => [
|
||||||
dataProvider={dataProvider}
|
<Resource name="artist" {...artist} options={{ subMenu: 'library' }} />,
|
||||||
authProvider={authProvider}
|
<Resource name="album" {...album} options={{ subMenu: 'library' }} />,
|
||||||
i18nProvider={i18nProvider}
|
<Resource name="song" {...song} options={{ subMenu: 'library' }} />,
|
||||||
customRoutes={customRoutes}
|
<Resource name="albumSong" />,
|
||||||
history={history}
|
permissions === 'admin' ? (
|
||||||
layout={Layout}
|
<Resource name="user" {...user} options={{ subMenu: 'settings' }} />
|
||||||
loginPage={Login}
|
) : null,
|
||||||
>
|
<Resource
|
||||||
{(permissions) => [
|
name="player"
|
||||||
|
{...player}
|
||||||
|
options={{ subMenu: 'settings' }}
|
||||||
|
/>,
|
||||||
|
permissions === 'admin' ? (
|
||||||
<Resource
|
<Resource
|
||||||
name="artist"
|
name="transcoding"
|
||||||
{...artist}
|
{...transcoding}
|
||||||
options={{ subMenu: 'library' }}
|
|
||||||
/>,
|
|
||||||
<Resource name="album" {...album} options={{ subMenu: 'library' }} />,
|
|
||||||
<Resource name="song" {...song} options={{ subMenu: 'library' }} />,
|
|
||||||
<Resource name="albumSong" />,
|
|
||||||
permissions === 'admin' ? (
|
|
||||||
<Resource name="user" {...user} options={{ subMenu: 'settings' }} />
|
|
||||||
) : null,
|
|
||||||
<Resource
|
|
||||||
name="player"
|
|
||||||
{...player}
|
|
||||||
options={{ subMenu: 'settings' }}
|
options={{ subMenu: 'settings' }}
|
||||||
/>,
|
/>
|
||||||
permissions === 'admin' ? (
|
) : (
|
||||||
<Resource
|
<Resource name="transcoding" />
|
||||||
name="transcoding"
|
),
|
||||||
{...transcoding}
|
<Player />
|
||||||
options={{ subMenu: 'settings' }}
|
]}
|
||||||
/>
|
</Admin>
|
||||||
) : (
|
</Provider>
|
||||||
<Resource name="transcoding" />
|
)
|
||||||
),
|
|
||||||
<Player />
|
|
||||||
]}
|
|
||||||
</Admin>
|
|
||||||
</Provider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default App
|
export default App
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ const authProvider = {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
// Validate token
|
// Validate token
|
||||||
jwtDecode(response.token)
|
jwtDecode(response.token)
|
||||||
localStorage.removeItem('initialAccountCreation')
|
|
||||||
localStorage.setItem('token', response.token)
|
localStorage.setItem('token', response.token)
|
||||||
localStorage.setItem('name', response.name)
|
localStorage.setItem('name', response.name)
|
||||||
localStorage.setItem('username', response.username)
|
localStorage.setItem('username', response.username)
|
||||||
@@ -35,6 +34,8 @@ const authProvider = {
|
|||||||
'subsonic-token',
|
'subsonic-token',
|
||||||
generateSubsonicToken(password, salt)
|
generateSubsonicToken(password, salt)
|
||||||
)
|
)
|
||||||
|
// Avoid going to create admin dialog after logout/login without a refresh
|
||||||
|
config.firstTime = false
|
||||||
return response
|
return response
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { fetchUtils } from 'react-admin'
|
import { fetchUtils } from 'react-admin'
|
||||||
import jsonServerProvider from 'ra-data-json-server'
|
import jsonServerProvider from 'ra-data-json-server'
|
||||||
import baseUrl from './utils/baseUrl'
|
import baseUrl from './utils/baseUrl'
|
||||||
|
import config from './config'
|
||||||
|
|
||||||
const restUrl = '/app/api'
|
const restUrl = '/app/api'
|
||||||
const customAuthorizationHeader = 'X-ND-Authorization'
|
const customAuthorizationHeader = 'X-ND-Authorization'
|
||||||
@@ -19,7 +20,8 @@ const httpClient = (url, options = {}) => {
|
|||||||
const token = response.headers.get(customAuthorizationHeader)
|
const token = response.headers.get(customAuthorizationHeader)
|
||||||
if (token) {
|
if (token) {
|
||||||
localStorage.setItem('token', token)
|
localStorage.setItem('token', token)
|
||||||
localStorage.removeItem('initialAccountCreation')
|
// Avoid going to create admin dialog after logout/login without a refresh
|
||||||
|
config.firstTime = false
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user