Skip to content

Commit

Permalink
Rename localStorage.token to ecthelion:token.
Browse files Browse the repository at this point in the history
This avoids conflicting with any other applications.
  • Loading branch information
retrixe committed Aug 7, 2023
1 parent 7d56160 commit 75a97ef
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions imports/dashboard/dashboardLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const DrawerItem = (props: { icon: React.ReactElement, name: string, subUrl: str
}

const onLogout = (): void => {
const token = localStorage.getItem('token')
localStorage.removeItem('token')
const token = localStorage.getItem('ecthelion:token')
localStorage.removeItem('ecthelion:token')
fetch(`${config.ip}/logout`, { headers: { Authorization: token ?? '' } }).catch(console.error)
}

Expand Down
2 changes: 1 addition & 1 deletion imports/dashboard/files/fileManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ const FileManager = (props: {
const handleDownloadButton = (): void => {
;(async () => {
handleCloseDownload()
// document.cookie = `X-Authentication=${localStorage.getItem('token')}`
// document.cookie = `X-Authentication=${localStorage.getItem('ecthelion:token')}`
const ticket = encodeURIComponent((await ky.get('ott').json<{ ticket: string }>()).ticket)
const loc = `${ip}/server/${server}/file?ticket=${ticket}&path=${euc(joinPath(path, download))}`
window.location.href = loc
Expand Down
2 changes: 1 addition & 1 deletion imports/errors/authFailure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const AuthFailure = (): JSX.Element => (
<Typography
style={{ textDecoration: 'underline' }}
onClick={() => {
try { localStorage.removeItem('token') } catch (e) { }
try { localStorage.removeItem('ecthelion:token') } catch (e) { }
}}
>Consider logging in?
</Typography>
Expand Down
2 changes: 1 addition & 1 deletion imports/helpers/useKy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const defaultKy = ky.create({
prefixUrl: config.ip,
hooks: {
beforeRequest: [
request => request.headers.set('Authorization', localStorage.getItem('token') ?? '')
request => request.headers.set('Authorization', localStorage.getItem('ecthelion:token') ?? '')
]
}
})
Expand Down
2 changes: 1 addition & 1 deletion imports/servers/serverList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const ServerList = ({ ip, node, setMessage, setFailure }: {
const runCommand = (command: string): void => {
;(async () => {
const ott = encodeURIComponent((await ky.get('ott').json<{ ticket: string }>()).ticket)
// document.cookie = `X-Authentication=${localStorage.getItem('token')}`
// document.cookie = `X-Authentication=${localStorage.getItem('ecthelion:token')}`
const ws = new WebSocket(`${ip.split('http').join('ws')}/server/${server}/console?ticket=${ott}`)
ws.onopen = () => {
ws.send(command)
Expand Down
4 changes: 2 additions & 2 deletions imports/settings/settingsLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const DrawerItem = (props: { icon: React.ReactElement, name: string, subUrl: str
}

const onLogout = (): void => {
const token = localStorage.getItem('token')
localStorage.removeItem('token')
const token = localStorage.getItem('ecthelion:token')
localStorage.removeItem('ecthelion:token')
fetch(`${config.ip}/logout`, { headers: { Authorization: token ?? '' } }).catch(console.error)
}

Expand Down
2 changes: 1 addition & 1 deletion pages/dashboard/[server]/console.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const Console = ({ setAuthenticated }: {
if (!server) return
try {
// Connect to console.
// document.cookie = `X-Authentication=${localStorage.getItem('token')}`
// document.cookie = `X-Authentication=${localStorage.getItem('ecthelion:token')}`
const ticket = await ky.get('ott')
if (ignore.current) return // If useEffect was called again by React, drop this.
setListening(true)
Expand Down
2 changes: 1 addition & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const Index = (): JSX.Element => {
const response = await request.json()
if (response.token || response.success) {
// Save the access token in localStorage if received in JSON body.
if (response.token) localStorage.setItem('token', response.token)
if (response.token) localStorage.setItem('ecthelion:token', response.token)
// Also, if authentication previously failed, let's just say it succeeded.
setFailedAuth(false)
setInvalid(false)
Expand Down
4 changes: 2 additions & 2 deletions pages/servers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import ConnectionFailure from '../imports/errors/connectionFailure'
const { ip, nodes } = config

const logout = (): void => {
const token = localStorage.getItem('token')
localStorage.removeItem('token')
const token = localStorage.getItem('ecthelion:token')
localStorage.removeItem('ecthelion:token')
fetch(`${config.ip}/logout`, { headers: { Authorization: token ?? '' } }).catch(console.error)
}

Expand Down

0 comments on commit 75a97ef

Please sign in to comment.