Skip to content

Commit

Permalink
Fix auth (#28)
Browse files Browse the repository at this point in the history
* Readme fixes (#3)

* more pretty stuff

* round 83

* aye ye

* deployment buttons

* fixes (#4)

* Realtime Features V1 (#6)

* wip

* new logo

* Move base components

* single catchall route at root

* Gallery aspect ratio

* fix useFiles

* fix directus urls

* bump deps

* typescript fixes

* cleanup

* Merge branch 'main' into realtime

* dynamic image updates

* new button sizes

* typescript blocks

* messenger search to help

* string utils to ts

* layout fixes

* button css

* typings for Directus plugin

* global search cleanup

* typescript fixes for components

* prettier updates

* formkit button fix

* type updates

* refactor og image route

* route cleanup

* help center

* messenger updates

* add typechecking

* button css notice

* help routes cleanup

* revert nuxt version because deploy issues

* button styling

* global search styling

* help center updates

* help center feedback

* cleanup

* more cleanup

* condition nuxt config

* try puppeteer core

* netlify toml

* another test combo

* another time

* forgot to pass options

* fix toml

* netlify deployment updates

* gallery updates

* gallery cleanup

* error handling

* separate function for vercel

* move to dev deps

* image generation

* remove chrome-aws-lamdba in favor of @sparticuz/chromium

* Layers (#7)

* refactor globals and redirects

* type global session

* typescript utils

* add micromark for md support (#8)

* Cleanup v1 (#9)

* add micromark for md support

* remove animation

* not functioning toc

* remove conversations page

* favicon

* final fix

* fix readme

* more cleanup

* add DIRECTUS_WS_URL to .env.example (#10)

* Update README.md (#11)

* proper types

* proper types

* remove old types

* remove old types

* switch to pnpm

* rijks rules

* github workflows

* meta fixes

* big wip

* swap /app for /portal

* remove unneeded composables

* remove app layer

* portal wip layer

* proposals wip layer

* update layouts

* add checkerboard bg to css for transparent images

* directory cleanup

* types updates

* utils

* nav changes

* fix types for blocks and reskin

* Fix og image

* directus module and plugin

* app config for nuxt ui

* base components overhaul

* typography overhaul

* help updates

* component changes

* move portals and proposals to layers

* page fixups

* global search

* styling

* nuxt config

* latest deps

* docker compose

* cleanup plugin

* logo swap

* illustration for empty state

* type fixes

* util updates

* update env example

* composable cleanup

* directus module

* new pages

* remove old plugin

* cache global search

* more cleanup

* portal wip

* proposal wip

* update nuxt

* readme updates

* theming

* component updates

* directus folder updates

* util formatting

* css cleanup

* block fixes

* base components

* help components

* nav comps

* tailwind config

* type fixes

* post template types

* portal layer wip2

* proposal layer wip2

* page fix ups

* server routes

* global theme + jsonld

* theming support

* directus compose latest

* component cleanup

* latest deps

* useFiles composable

* cleanup

* cleanup

* module console.log

* .github prepare action

* super typage

* sastify the typescript gods

* position logo on OG image

* remove unnessary import

* use env because runtime isn't defined in server/util

* duped color mode

* readme wip2

* readme wip3

* sitemap config

* directus module

* portal updates

* auth

* directus server util

* type fixups

* component updates

* cleanup

* docker compose updates

* add site config

* add toml file for netlify

* github actions

* from require to import

* try moveing toml

* one more time

* readme fixes

* lint fixes

* nooo go back

* fix auth

---------

Co-authored-by: oidt <thijmen@ogerion.nl>
  • Loading branch information
bryantgillespie and oidt authored Oct 24, 2023
1 parent 9342f85 commit 59a618f
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions modules/directus/runtime/plugins/directus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,15 @@ export default defineNuxtPlugin((nuxtApp) => {
const { isTokenExpired } = useDirectusAuth();

// We're creating a custom storage class to use the Nuxt so we can use auth on the server and clien
class CookieStorage implements AuthenticationStorage {
get(): Promise<AuthenticationData | null> | null {
class CookieStorage {
get() {
const cookie = useCookie('directus-auth');
const value = cookie.value;

if (value) {
return Promise.resolve(JSON.parse(value));
} else {
return null;
}
return cookie.value;
}

set(value: AuthenticationData | null): Promise<void> {
set(value: AuthenticationData) {
const cookie = useCookie('directus-auth');

if (value) {
cookie.value = JSON.stringify(value);
} else {
cookie.value = null;
}

return Promise.resolve();
cookie.value = value as any;
}
}

Expand All @@ -50,7 +37,7 @@ export default defineNuxtPlugin((nuxtApp) => {
fetch: $fetch, // We're using the built-in Nuxt $fetch from ofetch
},
})
.with(authentication('json', { storage: new CookieStorage(), credentials: 'include' }))
.with(authentication('json', { storage: new CookieStorage() as AuthenticationStorage, credentials: 'include' }))
.with(
rest({
onRequest: async (request) => {
Expand Down

0 comments on commit 59a618f

Please sign in to comment.