-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement authentication system
- Loading branch information
1 parent
6539187
commit eb6a0dc
Showing
8 changed files
with
109 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { createCookieSessionStorage } from "@remix-run/node"; | ||
|
||
type SessionData = { | ||
userId: string; | ||
}; | ||
|
||
type SessionFlashData = { | ||
error: string; | ||
}; | ||
|
||
const { getSession, commitSession, destroySession } = createCookieSessionStorage<SessionData, SessionFlashData>({ | ||
// a Cookie from `createCookie` or the CookieOptions to create one | ||
cookie: { | ||
name: "__session", | ||
|
||
// Expires can also be set (although maxAge overrides it when used in combination). | ||
// Note that this method is NOT recommended as `new Date` creates only one date on each server deployment, not a dynamic date in the future! | ||
// | ||
// expires: new Date(Date.now() + 60_000), | ||
httpOnly: true, | ||
maxAge: 60, | ||
path: "/", | ||
sameSite: "lax", | ||
secrets: ["s3cret1"], | ||
secure: true | ||
} | ||
}); | ||
|
||
export { getSession, commitSession, destroySession }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createProvider } from "@/src/shared/presentation/utils/zustand"; | ||
import type { AuthStateViewModel } from "../view-models/auth-state"; | ||
|
||
export const useAuthProvider = createProvider<AuthStateViewModel>(() => (_set) => ({ | ||
loggedIn: false | ||
})); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface AuthStateViewModel { | ||
loggedIn: boolean; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters