nuxt-auth-utils icon indicating copy to clipboard operation
nuxt-auth-utils copied to clipboard

feat: private session data

Open Gerbuuun opened this issue 2 years ago • 0 comments

I have added a public object to the SessionData which still contains the User type like before. The setUserSession and replaceUserSession have the parameters as described in #47

The SessionData type is no longer exposed in favor of PublicSessionData and PrivateSessionData. (only used internally from now on)

I'm not really sure about this solution yet. What I'm thinking is to let go of the user property as a session check and instead just use public like user is used right now. There won't be a built in computed user but this can easily be added by wrapping the useUserSession:

export default function userStore() {
  const { session, clear, fetch, loggedIn } = useUserSession();

  const user = computed(() => session.value.user || null);

  return {
    user,
    session,
    clear,
    fetch,
    loggedIn
  };
}

This way you don't have to use user and can add anything you want (as long as there is something) Problem is.. useUserSession is already taken as composable name

Gerbuuun avatar Mar 11 '24 23:03 Gerbuuun