diff --git a/backend/src/oauth2.rs b/backend/src/oauth2.rs index 87e2b84159..e07c1d8d2d 100644 --- a/backend/src/oauth2.rs +++ b/backend/src/oauth2.rs @@ -665,6 +665,7 @@ async fn slack_command( pub struct UserInfo { name: Option, company: Option, + displayName: Option, } async fn login_callback( @@ -807,6 +808,14 @@ async fn get_email(http_client: &Client, client_name: &str, token: &str) -> erro .email .to_string() } + "google" => http_get_user_info::( + http_client, + "https://www.googleapis.com/oauth2/v1/userinfo?alt=json", + token, + ) + .await? + .email + .to_string(), _ => { return Err(error::Error::BadRequest( "client name not recognized".to_string(), @@ -826,6 +835,19 @@ async fn get_user_info( "gitlab" => { http_get_user_info(http_client, "https://gitlab.com/api/v4/user", token).await? } + "google" => { + let google_user_info: UserInfo = http_get_user_info( + http_client, + "https://www.googleapis.com/oauth2/v1/userinfo?alt=json", + token, + ) + .await?; + UserInfo { + name: google_user_info.displayName.clone(), + company: None, + displayName: google_user_info.displayName, + } + } _ => { return Err(error::Error::BadRequest( "client name not recognized".to_string(), diff --git a/frontend/src/routes/user/login@user.svelte b/frontend/src/routes/user/login@user.svelte index eb3d6cc6fc..8e53b75a74 100644 --- a/frontend/src/routes/user/login@user.svelte +++ b/frontend/src/routes/user/login@user.svelte @@ -109,6 +109,15 @@ {/if} + {#if logins.includes('google')} + + {/if}