remix-auth
remix-auth copied to clipboard
Accept session in addition to request
Discussed in https://github.com/sergiodxa/remix-auth/discussions/142
Originally posted by ngbrown March 12, 2022
isAuthenticated
and logout
take a Request
just to get the session. The page very well could have already gotten a session and if it is a storage based session, then it would be advantageous to not fetch from the database multiple times.
My suggestion is to change the signature like this:
async logout(
request: Request | Session,
options: { redirectTo: string }
): Promise<void> {
const session = isSession(request)
? request
: await this._sessionStorage.getSession(request.headers.get("Cookie"));
// the rest is identical ...
}
isSession
is provided by remix
.