Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sshh12 committed Dec 25, 2024
1 parent 68778cf commit 7de5736
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def _enum_env(key, options: List[str], default: str) -> str:

# Secrets configuration
JWT_SECRET_KEY = os.getenv("JWT_SECRET_KEY", secrets.token_urlsafe(32))
JWT_EXPIRATION_DAYS = _int_env("JWT_EXPIRATION_DAYS", 10_000) # We don't have a sign back in feature
UNSPLASH_ACCESS_KEY = os.getenv("UNSPLASH_ACCESS_KEY")

# Modal config
Expand Down
5 changes: 2 additions & 3 deletions backend/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
from sqlalchemy.orm import Session
from datetime import datetime, timedelta
from jose import jwt, JWTError
from typing import Optional

from db.database import get_db
from db.models import User, Team, TeamMember, TeamRole
from schemas.models import UserCreate, UserResponse, AuthResponse, UserUpdate
from config import JWT_SECRET_KEY, CREDITS_DEFAULT
from config import JWT_SECRET_KEY, CREDITS_DEFAULT, JWT_EXPIRATION_DAYS

router = APIRouter(prefix="/api/auth", tags=["auth"])

Expand Down Expand Up @@ -64,7 +63,7 @@ async def create_user(user: UserCreate, db: Session = Depends(get_db)):
token = jwt.encode(
{
"sub": new_user.username,
"exp": datetime.now() + timedelta(days=10_000),
"exp": datetime.now() + timedelta(days=JWT_EXPIRATION_DAYS),
},
JWT_SECRET_KEY,
algorithm="HS256",
Expand Down
6 changes: 3 additions & 3 deletions backend/routers/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ async def get_project_zip(
**/node_modules/**
**/.next/**
**/build/**
/app/git.log
/app/tmp/**
/app/.git/**
**/git.log
**/tmp/**
**/.git/**
""".strip()
await sandbox.run_command(f"echo '{exclude_content}' > /tmp/zip-exclude.txt")
await sandbox.run_command("mkdir -p /app/tmp")
Expand Down
16 changes: 15 additions & 1 deletion frontend/src/context/user-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,21 @@ export function UserProvider({ children }) {

useEffect(() => {
if (localStorage.getItem('token')) {
api.getCurrentUser().then(setUser);
api
.getCurrentUser()
.then(setUser)
.catch((e) => {
if (e.message.includes('token')) {
localStorage.removeItem('token');
localStorage.removeItem('team');
setUser(null);
setTeam(null);
setChats([]);
setTeams([]);
setProjects([]);
window.location.href = '/';
}
});
fetchUserData();
}
}, []);
Expand Down
2 changes: 1 addition & 1 deletion images/NextjsShadcnDockerFile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN node --version && npm --version

RUN npx --yes create-next-app@latest frontend --js --tailwind --no-eslint --src-dir src --app --no-turbopack --yes && \
cd frontend && \
npm install lucide-react axios recharts --force && \
npm install lucide-react axios recharts @radix-ui/react-icons tailwind-merge react-hook-form --force && \
(echo "\n\n\n" | npx shadcn@latest init --defaults --force --yes) && \
(echo "\n\n\n" | npx shadcn@latest add --yes --all) && \
npm run build
Expand Down

0 comments on commit 7de5736

Please sign in to comment.