feat(auth): Implement Google OAuth 2.0 integration with user creation and JWT generation

- Added Google OAuth controller and service to handle authentication via Google.
- Introduced DTOs for Google user and token responses.
- Updated AuthService and UsersService traits to support new Google OAuth functionality.
- Implemented logic to create a new user if they do not exist in the system after Google authentication.
- Enhanced existing user retrieval and JWT generation upon successful login.
- Added tests for Google OAuth flow, including login redirection and callback handling for both new and existing users.
- Updated environment configuration to include Google OAuth credentials.
This commit is contained in:
MythEclipse
2025-08-11 22:31:51 +07:00
parent c6a95c1231
commit cda950ed7e
22 changed files with 1144 additions and 104 deletions
+5 -4
View File
@@ -1,9 +1,9 @@
use crate::{AppState, MetaRequestDto, v1::users_service::UsersService};
use crate::{AppState, MetaRequestDto};
use crate::{
MessageResponseDto, PermissionsEnum, ResponseListSuccessDto, ResponseSuccessDto,
UsersCreateRequestDto, UsersDetailItemDto, permissions_guard,
};
use axum::extract::{Path, Query};
use axum::extract::{Path}; // Removed Query
use axum::http::HeaderMap;
use axum::response::IntoResponse;
use axum::{Extension, Json};
@@ -11,6 +11,7 @@ use axum::{Extension, Json};
use super::{
UsersActiveInactiveRequestDto, UsersListItemDto, UsersUpdateRequestDto,
};
use crate::v1::users::users_service::{UsersServiceTrait, UsersService};
#[utoipa::path(
get,
@@ -35,7 +36,7 @@ use super::{
pub async fn get_user_list(
headers: HeaderMap,
Extension(state): Extension<AppState>,
Query(meta): Query<MetaRequestDto>,
Json(meta): Json<MetaRequestDto>,
) -> impl IntoResponse {
match permissions_guard(
&headers,
@@ -178,7 +179,7 @@ pub async fn put_update_user_me(
Json(payload): Json<UsersUpdateRequestDto>,
) -> impl IntoResponse {
match permissions_guard(&headers, state.clone(), vec![]).await {
Ok(_) => UsersService::update_user_me(&state, headers, payload).await,
Ok(_) => UsersService::update_user_me(headers, &state, payload).await,
Err(response) => response,
}
}