Skip to content

Commit

Permalink
Oh lol
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbate19 committed Oct 13, 2024
1 parent 73a35bb commit 7a3953a
Show file tree
Hide file tree
Showing 27 changed files with 567 additions and 136 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/api/v1/auth/csh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ async fn auth(
.unwrap();

sqlx::query!(
"INSERT INTO users (id, realm, name) VALUES ($1, $2, $3) ON CONFLICT (id) DO UPDATE SET realm = EXCLUDED.realm, name = EXCLUDED.name;",
"INSERT INTO users (id, realm, name, email) VALUES ($1, $2, $3, $4) ON CONFLICT (id) DO UPDATE SET realm = EXCLUDED.realm, name = EXCLUDED.name, email = EXCLUDED.email;",
user_info.ldap_id,
UserRealm::Csh as _,
format!("{} {}", user_info.given_name, user_info.family_name)
format!("{} {}", user_info.given_name, user_info.family_name),
user_info.email
)
.execute(&data.db)
.await.unwrap();
Expand Down
5 changes: 3 additions & 2 deletions src/api/v1/auth/google.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ async fn auth(
.unwrap();

sqlx::query!(
"INSERT INTO users (id, realm, name) VALUES ($1, $2, $3) ON CONFLICT (id) DO UPDATE SET realm = EXCLUDED.realm, name = EXCLUDED.name;",
"INSERT INTO users (id, realm, name, email) VALUES ($1, $2, $3, $4) ON CONFLICT (id) DO UPDATE SET realm = EXCLUDED.realm, name = EXCLUDED.name, email = EXCLUDED.email;",
user_info.sub,
UserRealm::Google as _,
format!("{} {}", user_info.given_name, user_info.family_name)
format!("{} {}", user_info.given_name, user_info.family_name),
user_info.email
)
.execute(&data.db)
.await.unwrap();
Expand Down
6 changes: 4 additions & 2 deletions src/api/v1/auth/models.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;

#[derive(sqlx::Type)]
#[derive(Serialize, Deserialize, sqlx::Type)]
#[sqlx(type_name = "user_realm", rename_all = "lowercase")]
pub enum UserRealm {
Csh,
Expand Down Expand Up @@ -38,11 +38,13 @@ pub struct UserInfo {
pub groups: Vec<String>,
}

#[derive(Serialize, Deserialize, sqlx::Type, ToSchema)]
#[derive(Serialize, Deserialize, sqlx::Type, ToSchema, Clone)]
#[serde(rename_all = "camelCase")]
pub struct UserData {
pub id: String,
pub realm: String,
pub name: String,
pub email: String,
}

impl From<CSHUserInfo> for UserInfo {
Expand Down
Loading

0 comments on commit 7a3953a

Please sign in to comment.