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:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user