@@ -28,39 +29,47 @@
diff --git a/src/session_storage.ts b/src/session_storage.ts
index 6d9543b..d00a813 100644
--- a/src/session_storage.ts
+++ b/src/session_storage.ts
@@ -1,5 +1,5 @@
import { getCookie, setCookie} from 'typescript-cookie'
-import { Session } from './lib/session'
+import { Session, TokenSession } from './lib/session'
@@ -10,53 +10,27 @@ export const nameCookie = (...s:string[]):string=>{
}
export class Storage {
- GetSessions():{[key:string]:Session} {
- const all_accounts = getCookie(nameCookie("all_accounts"))
- const accounts = all_accounts?.split(",")
- let out:{[key:string]:Session} = {};
- for (const account in accounts) {
- let tmp = {
- user: account,
- xsrf: getCookie(nameCookie("xsrf",account))!,
- lto: getCookie(nameCookie("lto",account))!,
- csrf: getCookie(nameCookie("csrf",account))!
- }
- out[account] = tmp
- }
- return out
- }
- RemoveSessions(...s:Session[]) {
- for(const v of s) {
- this.RemoveSession(v)
+
+ GetSession():Session {
+ const {user, xsrf, csrf} = {
+ user: getCookie(nameCookie("user"))!,
+ xsrf: getCookie(nameCookie("xsrf"))!,
+ csrf: getCookie(nameCookie("csrf"))!
}
+ return new TokenSession(user, xsrf, csrf)
}
- RemoveSession(s:Session) {
- const all_accounts = getCookie(nameCookie("all_accounts"))
- let accounts = all_accounts?.split(",")
- accounts = accounts ? accounts : []
- accounts = [...new Set(accounts)]
- accounts = accounts.filter(x=>x!=s.user)
-
- setCookie(nameCookie("all_accounts"),accounts.join(","))
- setCookie(nameCookie("lto",s.user), "")
- setCookie(nameCookie("xsrf",s.user),"")
+ RemoveSession() {
+ setCookie(nameCookie("user"),"")
+ setCookie(nameCookie("xsrf"),"")
+ setCookie(nameCookie("csrf"),"")
}
- AddSessions(...s:Session[]) {
- for(const v of s) {
- this.AddSession(v)
- }
- }
+
AddSession(s:Session) {
- const all_accounts = getCookie(nameCookie("all_accounts"))
- let accounts = all_accounts?.split(",")
- accounts = accounts ? accounts : []
- accounts.push(s.user)
- accounts = [...new Set(accounts)]
- setCookie(nameCookie("lto",s.user), s.lto)
- setCookie(nameCookie("xsrf",s.user),s.xsrf)
- setCookie(nameCookie("csrf",s.user),s.csrf)
+ setCookie(nameCookie("user"),s.user)
+ setCookie(nameCookie("xsrf"),s.xsrf)
+ setCookie(nameCookie("csrf"),s.csrf)
}
}
diff --git a/src/state/state.ts b/src/state/state.ts
new file mode 100644
index 0000000..a336b72
--- /dev/null
+++ b/src/state/state.ts
@@ -0,0 +1,25 @@
+import { defineStore, storeToRefs } from 'pinia'
+import { BasicColumns, ColumnInfo, ColumnName, Columns, DetailsColumns, MoveColumns } from '../lib/columns'
+import { ColumnSet } from '../lib/table'
+import { TricksterInventory } from '../lib/trickster'
+
+const _defaultColumn:(ColumnInfo| ColumnName)[] = [
+ ...BasicColumns,
+ ...MoveColumns,
+ ...DetailsColumns,
+]
+export const useStore = defineStore('state', {
+ state: ()=> {
+ return {
+ accounts: new Set() as Set,
+ invs: new Map() as Map,
+ activeTable: "none",
+ screen: "default",
+ columns: new ColumnSet(_defaultColumn),
+ tags: new ColumnSet(),
+ }
+ }
+})
+export const useStoreRef = ()=>{return storeToRefs(useStore())};
+
+
diff --git a/vite.config.ts b/vite.config.ts
index 680a3e4..81ed4f1 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -12,10 +12,6 @@ export default defineConfig({
target: "https://beta.lifeto.co/",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/lifeto/, ''),
- hostRewrite: "localhost:3001/lifeto",
- cookieDomainRewrite:{
- "*":"",
- },
},
}
}