atinux / nuxt-auth-utils

Add Authentication to Nuxt applications with secured & sealed cookies sessions.
MIT License
981 stars 91 forks source link

feat: private session data #65

Closed Gerbuuun closed 2 months ago

Gerbuuun commented 8 months ago

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 commented 2 months ago

implemented in #171