Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement user login #861

Draft
wants to merge 43 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9322570
Basic login
ShouvikGhosh2048 Sep 1, 2024
0cf48a5
Add user claims
ShouvikGhosh2048 Sep 2, 2024
c040edd
Implement verification
ShouvikGhosh2048 Sep 3, 2024
3eea913
Shift login to top right
ShouvikGhosh2048 Sep 3, 2024
1430714
tweak page URLs
otobot1 Sep 14, 2024
d691dcb
tweak wording on index page
otobot1 Sep 14, 2024
1cb0d26
Update schema.prisma
otobot1 Sep 15, 2024
e40cf99
refactor checkIsPrivileged to support arrays of targetUserIds
otobot1 Sep 15, 2024
009e6d7
remove unused variable
otobot1 Sep 15, 2024
87415b0
fix up tech and techVideo routers
otobot1 Sep 15, 2024
6959303
move userClaim pages into pages directory
otobot1 Sep 15, 2024
2f81244
refactor userClaim api
otobot1 Sep 15, 2024
34002f5
Update userClaim.ts
otobot1 Sep 15, 2024
0aed77a
create new baseline migration
otobot1 Sep 15, 2024
3fb089d
show "claim user" message to all users
otobot1 Sep 27, 2024
75eb0f7
Update /claim-user to work with API changes
otobot1 Sep 27, 2024
c1b21e9
increase query invalidation specificity
otobot1 Sep 28, 2024
a187771
prefer import syntax: `type {...}` over `{type ...}`
otobot1 Sep 28, 2024
119c1bc
refactoring, formatting, and referencing constants
otobot1 Sep 28, 2024
39e1cff
Update schema.prisma
otobot1 Sep 28, 2024
2fea675
resolve webpack errors
otobot1 Sep 28, 2024
da682d9
work on getting userClaim pages to load
otobot1 Sep 28, 2024
881b720
get /claim-user working and tweak styling and wording
otobot1 Oct 20, 2024
05781a5
get /claim-user/verify working
otobot1 Oct 20, 2024
f97d6e4
rename /claim-user to /claim-users
otobot1 Oct 20, 2024
5ef6367
fix double call of layout component
otobot1 Oct 20, 2024
8e2e119
update comment
otobot1 Oct 20, 2024
f5d09c2
update /claim-user pathname constants
otobot1 Oct 20, 2024
2b36ea7
add link to verify page from claim page
otobot1 Oct 20, 2024
70e52aa
address type error
otobot1 Oct 20, 2024
f27308a
tidy up types and adjust comments
otobot1 Oct 20, 2024
c54eb60
Update schema.prisma
otobot1 Oct 20, 2024
cecf355
resolve remaining TODOs
otobot1 Oct 20, 2024
fe926a9
remove remaining TODO!!! comments
otobot1 Oct 25, 2024
0db568f
remove old settings button and rearrange remaining footer links
otobot1 Jan 5, 2025
77021ea
cleanup header JSX
otobot1 Jan 5, 2025
c317643
add `as const`
otobot1 Jan 5, 2025
31ef5ef
finish cleaning up header JSX and fixing CSS
otobot1 Jan 5, 2025
ba70659
add more whitespace
otobot1 Jan 5, 2025
b7b63e0
add new settings button
otobot1 Jan 5, 2025
dad1ec0
Update schema.prisma
otobot1 Jan 6, 2025
447295c
revert dad1ec0d9a56c5ba57528811a8c09fe66cec7358
otobot1 Jan 6, 2025
98453c7
start troubleshooting verify user transaction
otobot1 Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion prisma/migrations/0_init/migration.sql
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,18 @@ CREATE TABLE `users-to-completed-maps` (
PRIMARY KEY (`userId`, `mapId`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `user-claim` (
`id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
`claimedBy` VARCHAR(191) NOT NULL,
`claimedUserId` VARCHAR(191) NOT NULL,
`approvedBy` VARCHAR(191) NULL,

INDEX `user-claim_claimedBy_idx`(`claimedBy`),
UNIQUE INDEX `user-claim_claimedBy_claimedUserId_key`(`claimedBy`, `claimedUserId`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `user` (
`id` VARCHAR(191) NOT NULL,
Expand Down Expand Up @@ -520,6 +532,7 @@ CREATE TABLE `session` (
`userId` VARCHAR(191) NOT NULL,
`expires` DATETIME(3) NOT NULL,

UNIQUE INDEX `session_sessionToken_key`(`sessionToken`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Expand Down Expand Up @@ -752,9 +765,17 @@ ALTER TABLE `users-to-completed-maps` ADD CONSTRAINT `users-to-completed-maps_us
-- AddForeignKey
ALTER TABLE `users-to-completed-maps` ADD CONSTRAINT `users-to-completed-maps_mapId_fkey` FOREIGN KEY (`mapId`) REFERENCES `map`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;

-- AddForeignKey
ALTER TABLE `user-claim` ADD CONSTRAINT `user-claim_claimedBy_fkey` FOREIGN KEY (`claimedBy`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;

-- AddForeignKey
ALTER TABLE `user-claim` ADD CONSTRAINT `user-claim_claimedUserId_fkey` FOREIGN KEY (`claimedUserId`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;

-- AddForeignKey
ALTER TABLE `user-claim` ADD CONSTRAINT `user-claim_approvedBy_fkey` FOREIGN KEY (`approvedBy`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;

-- AddForeignKey
ALTER TABLE `account` ADD CONSTRAINT `account_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;

-- AddForeignKey
ALTER TABLE `session` ADD CONSTRAINT `session_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;

174 changes: 96 additions & 78 deletions prisma/schema.prisma

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/filterPopovers/stringSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const StringSearch = ({ value, setValue, iconProps, difficultyIndex }: St
{...iconProps}
size={iconProps?.size ?? 18 /*TODO!!: get this from MantineTheme*/}
strokeWidth={iconProps?.strokeWidth ?? 1.5}
color={iconProps?.color ?? "white"}
color={iconProps?.color ?? "white" /*TODO!!: get this from MantineTheme*/}
/>
</ActionIcon>
}
Expand Down
31 changes: 21 additions & 10 deletions src/components/layout/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,30 @@ const useStyles = createStyles(
export const Footer = () => {
const { classes } = useStyles();


return (
<Box className={classes.outerFooter}>
<hr className={classes.horizontalRule} />
<footer className={classes.footer}>
<Box
className={classes.outerFooter}
>
<hr
className={classes.horizontalRule}
/>
<footer
className={classes.footer}
>
<Group
align="center"
grow
position="apart"
>
<Stack
align="start"
align="center"
spacing="1px"
>
<Link href={COMING_SOON_PATHNAME}>My Account</Link>
<Link href={COMING_SOON_PATHNAME}>Settings</Link>
<Link
href={COMING_SOON_PATHNAME}
>
Cookie Policy
</Link>
</Stack>
<Link
href={cmlDiscordInviteUrl}
Expand All @@ -61,11 +69,14 @@ export const Footer = () => {
Join Our Discord Server!
</Link>
<Stack
align="end"
align="center"
spacing="1px"
>
<Link href={COMING_SOON_PATHNAME}>Cookie Policy</Link>
<Link href={COMING_SOON_PATHNAME}>Privacy Policy</Link>
<Link
href={COMING_SOON_PATHNAME}
>
Privacy Policy
</Link>
</Stack>
</Group>
</footer>
Expand Down
188 changes: 156 additions & 32 deletions src/components/layout/header.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,174 @@
import { Flex, createStyles, Title, Box } from "@mantine/core";
import Link from "next/link";
import { Box, Group, Flex, createStyles, Title, Button, ActionIcon } from "@mantine/core";
import { signIn, signOut, useSession } from "next-auth/react";
import Image from "next/image";
import cmlLogo from "~/../public/images/logo/cml_logo.png";
import { blackBackgroundColor } from "~/styles/layoutColors";
import { Settings } from "tabler-icons-react";
import { blackBackgroundColor, blackBackgroundHoverColor } from "~/styles/layoutColors";
import { COMING_SOON_PATHNAME } from "~/consts/pathnames";
import { colorObject } from "~/styles/colorObjects";




const useStyles = createStyles(
(theme) => ({
header: {
color: theme.white,
backgroundColor: blackBackgroundColor,
padding: "10px 45px",
alignItems: "center",
},
siteTitle: {
fontSize: "45px",
flexGrow: 1,
textAlign: "center",
margin: "0",
}
})
(theme) => {
return ({
header: {
color: theme.white,
},
headerGroup: {
backgroundColor: blackBackgroundColor,
padding: "10px 45px", /*top and bottom | left and right*/
},
siteTitle: {
fontSize: "45px",
flexGrow: 1,
textAlign: "center",
margin: "0",
},
iconLink: {
padding: "0 4px 0 0", /* top | right | bottom | left */
},
userSettingsGroup: {
padding: "4px 2px 4px 4px", /* top | right | bottom | left */
columnGap: "5px",
borderRadius: "4px",
":hover": {
backgroundColor: blackBackgroundHoverColor,
},
"&&&&&": {
":active": {
transform: "translateY(0.0625rem)",
},
},
},
userName: {
":active": {
transform: "none",
},
},
icon: colorObject(theme.white),
iconInLink: {
margin: "2px",
},
iconNotInLink: {
padding: "4px 6px", /* top and bottom | left and right */
},
});
},
);




const USER_SETTINGS_ARIA_LABEL = "User settings";


const SettingsIcon = ({
className,
}: {
className: string;
}) => (
<Settings
className={className}
strokeWidth={2}
/>
);




export const Header = () => {
const { classes } = useStyles();
const height = 115;
const width = height / 694 * 774;
const HEIGHT = 115;
const width = HEIGHT / 694 * 774;


const { data: session } = useSession();


const { classes, cx } = useStyles();


return (
<header>
<Flex className={classes.header}>
<Image
priority
src={cmlLogo}
height={height}
width={width}
alt="CML Logo"
/>
<Title className={classes.siteTitle} order={1}>Celeste Mods List</Title>
<Box w={width} />
</Flex>
</header>
<header
className={classes.header}
>
<Group
className={classes.headerGroup} /* Must use a class to assign `backgroundColor` and `padding, as `Group` doesn't expose a `backgroundColor` prop. */
grow
align="center"
position="apart" /* justify-content = space-between */
>
<Flex
gap="1px 1px" /*row-gap column-gap*/
justify="start"
>
<Image
priority
src={cmlLogo}
width={width}
alt="CML Logo"
/>
</Flex>
<Title
className={classes.siteTitle}
order={1}
>Celeste Mods List
</Title>
<Flex
gap="1px 1px" /*row-gap column-gap*/
justify="end"
w={width}
>
{session && (
<>
<Link
className={classes.iconLink}
href={COMING_SOON_PATHNAME}
>
<Group
className={classes.userSettingsGroup}
align="center"
position="apart"
>
<span
className={classes.userName}
>
{session.user.name}
</span>
<SettingsIcon
className={cx(classes.icon, classes.iconInLink)}
/>
</Group>
</Link>
<Button
onClick={() => { void signOut(); }}
>
Logout
</Button>
</>
)}
{!session && (
<>
<Box
className={classes.iconNotInLink}
>
<ActionIcon>
<SettingsIcon
className={classes.icon}
/>
</ActionIcon>
</Box>
<Button
onClick={() => { void signIn("discord"); }}
>
Login
</Button>
</>
)}
</Flex>
</Group>
</header >
);
};
Loading
Loading