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:
@@ -0,0 +1,23 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct GoogleUser {
|
||||
pub id: String,
|
||||
pub email: String,
|
||||
pub verified_email: bool,
|
||||
pub name: String,
|
||||
pub given_name: String,
|
||||
pub family_name: String,
|
||||
pub picture: String,
|
||||
pub locale: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct GoogleTokenResponse {
|
||||
pub access_token: String,
|
||||
pub expires_in: u64,
|
||||
pub refresh_token: Option<String>,
|
||||
pub scope: String,
|
||||
pub token_type: String,
|
||||
pub id_token: String,
|
||||
}
|
||||
Reference in New Issue
Block a user