Skip to content

Commit 97681db

Browse files
fix: fix lint issues
1 parent 8db74eb commit 97681db

File tree

9 files changed

+32
-31
lines changed

9 files changed

+32
-31
lines changed

backend/src/auth/auth0_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
from authlib.integrations.starlette_client import OAuth
12
from fastapi import APIRouter, Request
23
from fastapi.responses import RedirectResponse
3-
from authlib.integrations.starlette_client import OAuth
4+
5+
from src.auth.services import get_or_create_user_by_email # Fix the import path
46
from src.core.config import settings
57
from src.core.db import get_db
6-
from src.auth.services import get_or_create_user_by_email # Fix the import path
8+
79
router = APIRouter(tags=["auth"])
810

911
oauth = OAuth()

backend/src/users/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import uuid
2-
from typing import TYPE_CHECKING, Optional
2+
from typing import TYPE_CHECKING
33

44
from sqlmodel import Field, Relationship
55

@@ -11,8 +11,8 @@
1111

1212
class User(UserBase, table=True):
1313
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
14-
auth0_id: Optional[str] = Field(default=None, index=True)
15-
hashed_password: Optional[str] = Field(default=None)
14+
auth0_id: str | None = Field(default=None, index=True)
15+
hashed_password: str | None = Field(default=None)
1616
collections: list["Collection"] = Relationship(
1717
back_populates="user",
1818
cascade_delete=True,

backend/src/users/schemas.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import uuid
2-
from typing import Optional
32

43
from pydantic import EmailStr
54
from sqlmodel import Field, SQLModel
@@ -17,8 +16,8 @@ class UserUpdate(UserBase):
1716

1817

1918
class UserCreate(UserBase):
20-
password: Optional[str] = Field(default=None, min_length=8, max_length=40)
21-
auth0_id: Optional[str] = None
19+
password: str | None = Field(default=None, min_length=8, max_length=40)
20+
auth0_id: str | None = None
2221

2322

2423
class UserRegister(SQLModel):
@@ -28,4 +27,4 @@ class UserRegister(SQLModel):
2827

2928
class UserPublic(UserBase):
3029
id: uuid.UUID
31-
auth0_id: Optional[str] = None
30+
auth0_id: str | None = None

backend/src/users/services.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
def create_user(*, session: Session, user_create: UserCreate) -> User:
1212
# Prepare update data
1313
update_data = {}
14-
14+
1515
# Only hash password if it's provided
1616
if user_create.password:
1717
update_data["hashed_password"] = get_password_hash(user_create.password)
18-
18+
1919
# Create user object
2020
db_obj = User.model_validate(user_create, update=update_data)
2121
session.add(db_obj)

frontend/src/components/commonUI/Drawer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Logo from '@/assets/Logo.svg'
2+
import { UsersService } from '@/client'
23
import type { Collection } from '@/client/types.gen'
34
import { useColorMode } from '@/components/ui/color-mode'
45
import {
@@ -17,7 +18,6 @@ import { useQuery } from '@tanstack/react-query'
1718
import { Link, useNavigate } from '@tanstack/react-router'
1819
import { useTranslation } from 'react-i18next'
1920
import { FiLogOut, FiMoon, FiSun } from 'react-icons/fi'
20-
import { UsersService } from '@/client'
2121
import { DefaultButton } from './Button'
2222
import LanguageSelector from './LanguageSelector'
2323

@@ -56,7 +56,7 @@ function Drawer({ isOpen, setIsOpen }: { isOpen: boolean; setIsOpen: (open: bool
5656
const { logout } = useAuth()
5757
const { colorMode, toggleColorMode } = useColorMode()
5858
const navigate = useNavigate()
59-
59+
6060
const { data: currentUser } = useQuery({
6161
queryKey: ['currentUser'],
6262
queryFn: async () => {
@@ -65,7 +65,7 @@ function Drawer({ isOpen, setIsOpen }: { isOpen: boolean; setIsOpen: (open: bool
6565
} catch (error) {
6666
return null
6767
}
68-
}
68+
},
6969
})
7070

7171
// Fetch collections data

frontend/src/hooks/useAuthContext.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { UsersService } from '@/client'
12
import type React from 'react'
23
import { createContext, useContext, useEffect, useState } from 'react'
3-
import { UsersService } from '@/client'
44

55
const GUEST_MODE_KEY = 'guest_mode'
66
const ACCESS_TOKEN_KEY = 'access_token'
@@ -16,12 +16,14 @@ const AuthContext = createContext<AuthContextType | undefined>(undefined)
1616

1717
function AuthProvider({ children }: { children: React.ReactNode }) {
1818
const [isGuest, setIsGuest] = useState(() => localStorage.getItem(GUEST_MODE_KEY) === 'true')
19-
const [isLoggedIn, setIsLoggedIn] = useState(() =>
20-
Boolean(localStorage.getItem(ACCESS_TOKEN_KEY)) || localStorage.getItem(GUEST_MODE_KEY) === 'true'
19+
const [isLoggedIn, setIsLoggedIn] = useState(
20+
() =>
21+
Boolean(localStorage.getItem(ACCESS_TOKEN_KEY)) ||
22+
localStorage.getItem(GUEST_MODE_KEY) === 'true',
2123
)
2224

2325
useEffect(() => {
24-
console.log("isLoggedIn", isLoggedIn)
26+
console.log('isLoggedIn', isLoggedIn)
2527

2628
const checkUser = async () => {
2729
if (localStorage.getItem(GUEST_MODE_KEY) === 'true') {
@@ -49,7 +51,7 @@ function AuthProvider({ children }: { children: React.ReactNode }) {
4951
setIsGuest(localStorage.getItem(GUEST_MODE_KEY) === 'true')
5052
setIsLoggedIn(
5153
Boolean(localStorage.getItem(ACCESS_TOKEN_KEY)) ||
52-
localStorage.getItem(GUEST_MODE_KEY) === 'true'
54+
localStorage.getItem(GUEST_MODE_KEY) === 'true',
5355
)
5456
}
5557
}
@@ -94,4 +96,4 @@ function useAuthContext() {
9496
return ctx
9597
}
9698

97-
export { AuthProvider, useAuthContext }
99+
export { AuthProvider, useAuthContext }

frontend/src/routes/_layout.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1+
import { UsersService } from '@/client'
12
import Navbar from '@/components/commonUI/Navbar'
23
import { Toaster } from '@/components/ui/toaster'
3-
import { UsersService } from '@/client'
44
import { Container } from '@chakra-ui/react'
55
import { Outlet, createFileRoute, redirect } from '@tanstack/react-router'
66

77
export const Route = createFileRoute('/_layout')({
88
component: Layout,
99
beforeLoad: async () => {
10-
const isGuest = localStorage.getItem('guest_mode') === 'true';
10+
const isGuest = localStorage.getItem('guest_mode') === 'true'
1111
if (isGuest) {
12-
return;
12+
return
1313
}
1414
try {
15-
const user = await UsersService.readUserMe();
15+
const user = await UsersService.readUserMe()
1616
if (!user) {
17-
throw redirect({ to: '/login' });
17+
throw redirect({ to: '/login' })
1818
}
1919
} catch (err) {
20-
console.error('Failed to check auth state:', err);
21-
throw redirect({ to: '/login' });
20+
console.error('Failed to check auth state:', err)
21+
throw redirect({ to: '/login' })
2222
}
23-
}
23+
},
2424
})
2525

2626
function Layout() {

frontend/src/routes/_publicLayout/login.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Logo from '@/assets/Logo.svg'
2+
import { UsersService } from '@/client'
23
import useAuth from '@/hooks/useAuth'
34
import { Box, Container, Field, Fieldset, HStack, Image, Text, VStack } from '@chakra-ui/react'
45
import { Link, createFileRoute, redirect } from '@tanstack/react-router'
@@ -9,7 +10,6 @@ import { DefaultButton } from '../../components/commonUI/Button'
910
import { GoogleAuthButton } from '../../components/commonUI/GoogleAuthButton'
1011
import { DefaultInput } from '../../components/commonUI/Input'
1112
import { emailPattern } from '../../utils'
12-
import { UsersService } from '@/client'
1313

1414
export const Route = createFileRoute('/_publicLayout/login')({
1515
component: Login,
@@ -26,7 +26,6 @@ export const Route = createFileRoute('/_publicLayout/login')({
2626
},
2727
})
2828

29-
3029
function Login() {
3130
const { t } = useTranslation()
3231
const { loginMutation, error, resetError } = useAuth()

frontend/src/routes/_publicLayout/signup.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function SignUp() {
6767
// This function will be implemented later when we add Auth0 integration
6868
console.log('Google signup clicked')
6969
window.location.href = 'http://localhost:8000/api/v1/auth0/login'
70-
7170
}
7271

7372
return (

0 commit comments

Comments
 (0)