-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
85 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ pub mod error; | |
mod id; | ||
pub mod password; | ||
pub mod token; | ||
pub mod user; | ||
|
||
pub use id::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::error::{self, Result}; | ||
use iam_entity::users; | ||
use sea_orm::{ConnectionTrait, EntityTrait, FromQueryResult}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, FromQueryResult, Serialize, Deserialize, PartialEq, Eq)] | ||
pub struct UserInfo { | ||
pub id: String, | ||
pub name: String, | ||
pub email: String, | ||
} | ||
|
||
pub async fn get_user<D>(db: &D, id: &str) -> Result<UserInfo> | ||
where | ||
D: ConnectionTrait, | ||
{ | ||
users::Entity::find_by_id(id.to_owned()) | ||
.into_model() | ||
.one(db) | ||
.await? | ||
.ok_or(error::USER_NOT_FOUND) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod actions; | ||
pub mod apps; | ||
mod db; | ||
pub mod users; | ||
|
||
pub use db::Database; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pub use iam_common::user::UserInfo; | ||
use sea_orm::ConnectionTrait; | ||
|
||
pub async fn get_user<D>(db: &D, id: &str) -> UserInfo | ||
where | ||
D: ConnectionTrait, | ||
{ | ||
iam_common::user::get_user(db, id) | ||
.await | ||
.expect("failed to get user") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters