Skip to content

Commit c40ba7e

Browse files
committed
refactor: Enhance auth configuration with TypeScript types and improve session handling
- Added TypeScript types for Session, JWT, and NextAuthUser to improve type safety in auth.ts. - Updated the authorize, jwt, and session callbacks to utilize these types, enhancing clarity and maintainability. - Adjusted eslint configuration to ignore specific directories and updated linting commands in package.json for consistency.
1 parent 5282ee3 commit c40ba7e

6 files changed

Lines changed: 44 additions & 15 deletions

File tree

app/(landing)/about/OurTeam.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33

44
const OurTeam = () => {
55
return (
6-
<div className='lg:p-25 p-8'>
6+
<div>
77
<p
88
className='text-sm font-medium bg-clip-text text-transparent w-fit mx-auto'
99
style={{
@@ -18,7 +18,7 @@ const OurTeam = () => {
1818
Meet the Brains Behind Boundless
1919
</h1>
2020
<p
21-
className='mt-2 bg-clip-text text-transparent lg:w-2/5 mx-auto '
21+
className='mt-2 bg-clip-text text-transparent text-center lg:w-2/5 mx-auto '
2222
style={{
2323
backgroundImage:
2424
'linear-gradient(93.2deg, #B5B5B5 15.93%, #FFFFFF 73.28%)',

app/(landing)/about/Partners.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import React from 'react';
44

55
const Partners = () => {
66
return (
7-
<div className='lg:py-50 md:py-36 sm:py-25 py-16 lg:px-25 md:px-20 sm:px-12 px-5'>
8-
<h1 className='lg:text-5xl md:text-4xl text-[32px]'>
7+
<div className='text-center'>
8+
<h1 className='lg:text-5xl md:text-4xl text-[32px] text-white'>
99
Backed by Trusted Partners
1010
</h1>
1111
<p

app/(landing)/about/page.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ import { Metadata } from 'next';
33
import { generatePageMetadata } from '@/lib/metadata';
44
import TestimonialsSection from '@/components/testimonials/TestimonialsSection';
55
import { testimonials } from '@/components/testimonials/data/testimonial';
6+
import OurTeam from './OurTeam';
7+
import Partners from './Partners';
68

79
export const metadata: Metadata = generatePageMetadata('about');
810

911
const AboutPage = () => {
1012
return (
11-
<div className='text-white text-4xl font-bold text-center mt-10'>
12-
<TestimonialsSection testimonials={testimonials} />
13+
<div className='relative z-10 space-y-[23px] md:space-y-[80px] max-w-[1300px] mx-auto'>
14+
<OurTeam />
15+
<Partners />
16+
<div className='text-white text-4xl font-bold text-center mt-10'>
17+
<TestimonialsSection testimonials={testimonials} />
18+
</div>
1319
</div>
1420
);
1521
};

auth.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import NextAuth from 'next-auth';
2+
import type { Session } from 'next-auth';
3+
import type { JWT } from 'next-auth/jwt';
4+
import type { User as NextAuthUser } from 'next-auth';
25
import Credentials from 'next-auth/providers/credentials';
36
import { login, getMe as getMeBase } from '@/lib/api/auth';
47
import Google from 'next-auth/providers/google';
@@ -89,7 +92,11 @@ export const authConfig = {
8992
password: { label: 'Password', type: 'password' },
9093
accessToken: { label: 'Access Token', type: 'text' },
9194
},
92-
authorize: async (credentials: any) => {
95+
authorize: async (
96+
credentials:
97+
| Partial<Record<'email' | 'password' | 'accessToken', unknown>>
98+
| undefined
99+
) => {
93100
if (
94101
typeof credentials?.accessToken === 'string' &&
95102
!credentials?.email &&
@@ -152,21 +159,28 @@ export const authConfig = {
152159
}),
153160
],
154161
callbacks: {
155-
authorized: async ({ auth }: { auth: any }) => {
162+
authorized: async ({ auth }: { auth: Session | null }) => {
156163
// Logged in users are authenticated, otherwise redirect to login page
157164
return !!auth;
158165
},
159-
async jwt({ token, user }: any) {
166+
async jwt({ token, user }: { token: JWT; user?: NextAuthUser | null }) {
160167
if (user) {
161-
const u = user as { accessToken?: string; refreshToken?: string };
168+
const u = user as NextAuthUser & {
169+
accessToken?: string;
170+
refreshToken?: string;
171+
};
162172
token.accessToken = u.accessToken;
163173
token.refreshToken = u.refreshToken;
164174
}
165175
return token;
166176
},
167-
async session({ session, token }: any) {
168-
session.user.accessToken = token.accessToken as string | undefined;
169-
session.user.refreshToken = token.refreshToken as string | undefined;
177+
async session({ session, token }: { session: Session; token: JWT }) {
178+
session.user.accessToken = (
179+
token as JWT & { accessToken?: string }
180+
).accessToken;
181+
session.user.refreshToken = (
182+
token as JWT & { refreshToken?: string }
183+
).refreshToken;
170184
return session;
171185
},
172186
},

eslint.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ const compat = new FlatCompat({
1010
});
1111

1212
const eslintConfig = [
13+
{
14+
ignores: [
15+
'node_modules/**',
16+
'.next/**',
17+
'out/**',
18+
'build/**',
19+
'next-env.d.ts',
20+
],
21+
},
1322
...compat.extends(
1423
'next/core-web-vitals',
1524
'next/typescript',

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"dev": "next dev",
77
"build": "next build",
88
"start": "next start",
9-
"lint": "next lint",
9+
"lint": "eslint .",
1010
"type-check": "tsc --noEmit",
1111
"format": "prettier --write .",
1212
"format:check": "prettier --check .",
13-
"lint:fix": "next lint --fix",
13+
"lint:fix": "eslint --fix .",
1414
"prepare": "husky install"
1515
},
1616
"lint-staged": {

0 commit comments

Comments
 (0)