Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ PORT=8000
FRONTEND_URL=http://localhost:3000
API_URL=http://localhost:8000

# Google OAuth (optional; required only for "Sign in with Google")
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URL=http://localhost:8000/api/v1/auth/google/callback

# Frontend
NEXT_PUBLIC_API_URL=http://localhost:8000/api/v1

Expand Down
10 changes: 10 additions & 0 deletions backend/api/src/api/handlers/auth_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ pub struct OAuthCallbackQuery {

pub async fn google_login() -> Result<axum::response::Redirect, AppError> {
let client_id = std::env::var("GOOGLE_CLIENT_ID").unwrap_or_default();
if client_id.trim().is_empty() {
return Err(AppError::BadRequest(
"Google OAuth is not configured. Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET.".into(),
));
}
let redirect_uri = std::env::var("GOOGLE_REDIRECT_URL")
.unwrap_or_else(|_| "http://localhost:8000/api/v1/auth/google/callback".to_string());

Expand All @@ -219,6 +224,11 @@ pub async fn google_callback(
) -> Result<axum::response::Redirect, AppError> {
let client_id = std::env::var("GOOGLE_CLIENT_ID").unwrap_or_default();
let client_secret = std::env::var("GOOGLE_CLIENT_SECRET").unwrap_or_default();
if client_id.trim().is_empty() || client_secret.trim().is_empty() {
return Err(AppError::BadRequest(
"Google OAuth is not configured. Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET.".into(),
));
}
let redirect_uri = std::env::var("GOOGLE_REDIRECT_URL")
.unwrap_or_else(|_| "http://localhost:8000/api/v1/auth/google/callback".to_string());
let frontend_url =
Expand Down
Loading