clenaup cookie bullshit after api-deux pr merged (#2151)
* clenaup cookie bullshit after api-deux pr merged Signed-off-by: Jess Frazelle <github@jessfraz.com> * check empty Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -41,7 +41,6 @@
|
||||
"fuse.js": "^7.0.0",
|
||||
"html2canvas-pro": "^1.4.3",
|
||||
"http-server": "^14.1.1",
|
||||
"js-cookie": "^3.0.5",
|
||||
"json-rpc-2.0": "^1.6.0",
|
||||
"jszip": "^3.10.1",
|
||||
"node-fetch": "^3.3.2",
|
||||
@ -123,7 +122,6 @@
|
||||
"@tauri-apps/cli": "^2.0.0-beta.13",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/debounce-promise": "^3.1.9",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/pixelmatch": "^5.2.6",
|
||||
"@types/pngjs": "^6.0.4",
|
||||
"@types/react-modal": "^3.16.3",
|
||||
|
@ -4,7 +4,6 @@ import withBaseURL from '../lib/withBaseURL'
|
||||
import { isTauri } from 'lib/isTauri'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import { VITE_KC_API_BASE_URL } from 'env'
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
const SKIP_AUTH =
|
||||
import.meta.env.VITE_KC_SKIP_AUTH === 'true' && import.meta.env.DEV
|
||||
@ -135,35 +134,18 @@ async function getUser(context: UserContext) {
|
||||
hostname: VITE_KC_API_BASE_URL,
|
||||
}).catch((err) => console.error('error from Tauri getUser', err))
|
||||
|
||||
const tokenPromise = !isTauri()
|
||||
? fetch(withBaseURL('/user/api-tokens?limit=1'), {
|
||||
method: 'GET',
|
||||
credentials: 'include',
|
||||
headers,
|
||||
})
|
||||
.then(async (res) => {
|
||||
const result: Models['ApiTokenResultsPage_type'] = await res.json()
|
||||
return result.items[0].token
|
||||
})
|
||||
.catch((err) => console.error('error from Browser getUser', err))
|
||||
: context.token
|
||||
|
||||
const user = await userPromise
|
||||
const token = await tokenPromise
|
||||
|
||||
if ('error_code' in user) throw new Error(user.message)
|
||||
|
||||
console.log('context.token "', context.token, '"')
|
||||
console.log('cookie "', getCookie(COOKIE_NAME), '"')
|
||||
console.log(
|
||||
'localStorage.getItem(TOKEN_PERSIST_KEY) "',
|
||||
localStorage?.getItem(TOKEN_PERSIST_KEY),
|
||||
'"'
|
||||
)
|
||||
|
||||
return {
|
||||
user,
|
||||
token,
|
||||
token:
|
||||
context.token && context.token !== ''
|
||||
? context.token
|
||||
: getCookie(COOKIE_NAME) ||
|
||||
localStorage?.getItem(TOKEN_PERSIST_KEY) ||
|
||||
'',
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,8 +154,6 @@ function getCookie(cname: string): string | null {
|
||||
return null
|
||||
}
|
||||
|
||||
console.log('cookies', Cookies.get())
|
||||
|
||||
let name = cname + '='
|
||||
let decodedCookie = decodeURIComponent(document.cookie)
|
||||
let ca = decodedCookie.split(';')
|
||||
|
10
yarn.lock
10
yarn.lock
@ -2417,11 +2417,6 @@
|
||||
expect "^29.0.0"
|
||||
pretty-format "^29.0.0"
|
||||
|
||||
"@types/js-cookie@^3.0.6":
|
||||
version "3.0.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/js-cookie/-/js-cookie-3.0.6.tgz#a04ca19e877687bd449f5ad37d33b104b71fdf95"
|
||||
integrity sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==
|
||||
|
||||
"@types/json-schema@*", "@types/json-schema@^7.0.9":
|
||||
version "7.0.12"
|
||||
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.12.tgz#d70faba7039d5fca54c83c7dbab41051d2b6f6cb"
|
||||
@ -6237,11 +6232,6 @@ joi@^17.11.0:
|
||||
"@sideway/formula" "^3.0.1"
|
||||
"@sideway/pinpoint" "^2.0.0"
|
||||
|
||||
js-cookie@^3.0.5:
|
||||
version "3.0.5"
|
||||
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-3.0.5.tgz#0b7e2fd0c01552c58ba86e0841f94dc2557dcdbc"
|
||||
integrity sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==
|
||||
|
||||
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||
|
Reference in New Issue
Block a user