Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit 458c839

Browse files
committed
feat(portal): scaffold auth
1 parent c730731 commit 458c839

File tree

6 files changed

+56
-8
lines changed

6 files changed

+56
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { auth } from "@/lib/auth";
2+
import { toNextJsHandler } from "better-auth/next-js";
3+
4+
export const { GET, POST } = toNextJsHandler(auth.handler);

apps/axiom/src/payload.config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// THEME CREDITS: github.com/akhrarovsaid/payload-theme-quantum-leap
22
// github.com/jhb-software/payload-plugins/tree/main/geocoding
33
import path from "node:path";
4-
// import { s3Storage } from '@payloadcms/storage-s3'
54
/* eslint-disable node/prefer-global/process */
5+
// import { s3Storage } from '@payloadcms/storage-s3'
66
import { fileURLToPath } from "node:url";
77
import {
8-
// googleOAuth,
9-
linkedinOAuth } from '@/cms/endpoints/auth'
8+
googleOAuth,
9+
linkedinOAuth
10+
} from '@/cms/endpoints/auth'
1011
import {Brands} from "@/db/collections"
1112
import { Media, Users, Emails } from "@/db/collections/models";
1213
import {Website, SocialLinks} from "@/db/collections/globals";
@@ -102,6 +103,8 @@ export default buildConfig({
102103
generateSchemaOutputFile: path.resolve("../../libs/db/schema.ts"),
103104
}),
104105
plugins: [
106+
googleOAuth,
107+
linkedinOAuth
105108
// process.env.NODE_ENV == 'production' && s3Storage({
106109
// collections: {
107110
// media: {
@@ -120,8 +123,5 @@ export default buildConfig({
120123
// endpoint: process.env.S3_ENDPOINT,
121124
// },
122125
// }),
123-
// googleOAuth,
124-
linkedinOAuth
125-
// payloadCloudPlugin(),
126126
],
127127
});

auth.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {
2+
betterAuth
3+
} from 'better-auth';
4+
5+
export const auth = betterAuth({
6+
socialProviders: {
7+
linkedin: {
8+
clientId: process.env.LINKEDIN_CLIENT_ID,
9+
clientSecret: process.env.LINKEDIN_CLIENT_SECRET
10+
}
11+
},
12+
13+
/** if no database is provided, the user data will be stored in memory.
14+
* Make sure to provide a database to persist user data **/
15+
});

libs/db/payload-types.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export interface User {
213213
* This could be a company, university, or student club.
214214
*/
215215
brandRelation?: (number | null) | Brand;
216-
linkedIn?: string | null;
216+
linkedin?: string | null;
217217
discord?: string | null;
218218
github?: string | null;
219219
behance?: string | null;
@@ -264,6 +264,11 @@ export interface User {
264264
emergencyContactFullName?: string | null;
265265
emergencyContactCell?: string | null;
266266
emergencyContactEmailAddress?: string | null;
267+
linkedinSub?: string | null;
268+
linkedinEmailVerified?: string | null;
269+
linkedinLocale?: string | null;
270+
googleSub?: string | null;
271+
googleEmailVerified?: string | null;
267272
sub?: string | null;
268273
updatedAt: string;
269274
createdAt: string;
@@ -432,7 +437,7 @@ export interface UsersSelect<T extends boolean = true> {
432437
pronouns?: T;
433438
avatar?: T;
434439
brandRelation?: T;
435-
linkedIn?: T;
440+
linkedin?: T;
436441
discord?: T;
437442
github?: T;
438443
behance?: T;
@@ -443,6 +448,11 @@ export interface UsersSelect<T extends boolean = true> {
443448
emergencyContactFullName?: T;
444449
emergencyContactCell?: T;
445450
emergencyContactEmailAddress?: T;
451+
linkedinSub?: T;
452+
linkedinEmailVerified?: T;
453+
linkedinLocale?: T;
454+
googleSub?: T;
455+
googleEmailVerified?: T;
446456
sub?: T;
447457
updatedAt?: T;
448458
createdAt?: T;

libs/portal/features/login/ui/call-to-action.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Button } from '@cuhacking/shared/ui/button'
33
import { GlassmorphicCard } from '@cuhacking/shared/ui/glassmorphic-card'
44
import { Typography } from '@cuhacking/shared/ui/typography'
55
import { Form, useNavigation } from '@remix-run/react'
6+
import { signIn } from '../../../pages/login/index'
67

78
export function LoginCallToAction() {
89
const transition = useNavigation()
@@ -28,6 +29,12 @@ export function LoginCallToAction() {
2829
className="flex items-center gap-x-3 px-4 md:px-6 lg:px-8 py-4"
2930
aria-label="Login with Linkedin"
3031
disabled={transition.state === 'submitting'}
32+
onClick={async () => {
33+
await signIn.social({
34+
provider: 'linkedin',
35+
callbackURL: '/hello',
36+
})
37+
}}
3138
>
3239
<img src={linkedinBlack} alt="Linkedin logo" className="size-5" />
3340
<Typography variant="h6">Log In</Typography>

libs/portal/pages/login/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
import dashboard_background from '@cuhacking/portal/assets/backgrounds/dashboard-bg-1.webp'
22
import { LoginCallToAction } from '@cuhacking/portal/features/login'
3+
import { createAuthClient } from 'better-auth/react'
4+
5+
export const authClient = createAuthClient({
6+
baseURL: process.env.development ? process.env.CUHACKING_2025_AXIOM_LOCAL_URL : process.env.CUHACKING_2025_AXIOM_PUBLIC_URL,
7+
})
8+
9+
export const {
10+
signIn,
11+
signOut,
12+
signUp,
13+
useSession,
14+
} = authClient
315

416
export function Login() {
517
return (

0 commit comments

Comments
 (0)