-
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.
- Loading branch information
Showing
31 changed files
with
281 additions
and
129 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
|
@@ -120,6 +120,7 @@ model UserEmailChange { | |
} | ||
|
||
enum Role { | ||
SuperAdmin | ||
Admin | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -3,6 +3,15 @@ import { PrismaClient, Role } from "@prisma/client"; | |
const prisma = new PrismaClient(); | ||
|
||
const devSeed = async () => { | ||
await prisma.user.create({ | ||
data: { | ||
email: "[email protected]", | ||
UserRole: { | ||
create: [{ role: Role.SuperAdmin }, { role: Role.Admin }], | ||
}, | ||
}, | ||
}); | ||
|
||
await prisma.user.create({ | ||
data: { | ||
email: "[email protected]", | ||
|
@@ -223,16 +232,14 @@ const prodSeed = async () => { | |
data: { | ||
email: "[email protected]", | ||
UserRole: { | ||
create: { | ||
role: Role.Admin, | ||
}, | ||
create: [{ role: Role.SuperAdmin }, { role: Role.Admin }], | ||
}, | ||
}, | ||
}); | ||
}; | ||
|
||
if (process.env.NODE_ENV === "production") { | ||
prodSeed(); | ||
await prodSeed(); | ||
} else { | ||
devSeed(); | ||
await devSeed(); | ||
} |
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,35 @@ | ||
import { serialize } from "cookie"; | ||
|
||
import { SIGN_IN_REDIRECT_COOKIE_NAME } from "../shared/constants"; | ||
|
||
import { trpc } from "./trpc"; | ||
|
||
const noop = async () => { | ||
// do nothing | ||
}; | ||
|
||
export const authProvider = { | ||
checkAuth: async () => { | ||
const isSignedIn = await trpc.authentication.isSignedIn.query(); | ||
if (!isSignedIn) { | ||
document.cookie = serialize(SIGN_IN_REDIRECT_COOKIE_NAME, "/admin"); | ||
location.href = "/sign-in"; | ||
return; | ||
} | ||
|
||
const roles = await trpc.authentication.roles.query(); | ||
if (roles.includes("SuperAdmin") || roles.includes("Admin")) { | ||
return; | ||
} | ||
location.href = "/"; | ||
}, | ||
|
||
logout: async () => { | ||
await trpc.authentication.signOut.mutate(); | ||
location.href = "/"; | ||
}, | ||
|
||
login: noop, | ||
checkError: noop, | ||
getPermissions: noop, | ||
}; |
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,8 @@ | ||
import { createRoot } from "react-dom/client"; | ||
|
||
import { App } from "./app"; | ||
|
||
const rootElement = document.getElementById("root"); | ||
if (rootElement) { | ||
createRoot(rootElement).render(<App />); | ||
} |
File renamed without changes.
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
File renamed without changes.
Oops, something went wrong.