mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-09 00:04:10 +00:00
feat: add google login v1
This commit is contained in:
@@ -665,6 +665,7 @@ async fn slack_command(
|
||||
pub struct UserInfo {
|
||||
name: Option<String>,
|
||||
company: Option<String>,
|
||||
displayName: Option<String>,
|
||||
}
|
||||
|
||||
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::<EmailInfo>(
|
||||
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(),
|
||||
|
||||
@@ -109,6 +109,15 @@
|
||||
</button></a
|
||||
>
|
||||
{/if}
|
||||
{#if logins.includes('google')}
|
||||
<a rel="external" href="/api/oauth/login/google"
|
||||
><button
|
||||
class="m-auto default-button bg-gray-100 mt-2 py-2 w-full text-black hover:bg-blue-300"
|
||||
>Google
|
||||
<Icon class="pb-1" data={faGitlab} scale={1.4} />
|
||||
</button></a
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex flex-row-reverse w-full">
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user