feat: add ctx.name to apps #4885
This commit is contained in:
@@ -11216,6 +11216,8 @@ components:
|
||||
type: string
|
||||
is_admin:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
is_super_admin:
|
||||
type: boolean
|
||||
created_at:
|
||||
|
||||
@@ -847,6 +847,7 @@ pub struct UserInfo {
|
||||
pub folders_read: Vec<String>,
|
||||
pub folders: Vec<String>,
|
||||
pub folders_owners: Vec<String>,
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(FromRow, Serialize)]
|
||||
@@ -1218,6 +1219,7 @@ async fn whoami(
|
||||
workspace_id: w_id,
|
||||
email: email.clone(),
|
||||
username: email,
|
||||
name: None,
|
||||
is_admin,
|
||||
is_super_admin: is_admin,
|
||||
created_at: chrono::Utc::now(),
|
||||
@@ -1306,22 +1308,30 @@ async fn get_usage(
|
||||
Ok(usage.to_string())
|
||||
}
|
||||
|
||||
#[derive(FromRow, Serialize)]
|
||||
pub struct User2 {
|
||||
pub workspace_id: String,
|
||||
pub email: String,
|
||||
pub username: String,
|
||||
pub is_admin: bool,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
pub operator: bool,
|
||||
pub disabled: bool,
|
||||
pub role: Option<String>,
|
||||
pub super_admin: bool,
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
async fn get_user(w_id: &str, username: &str, db: &DB) -> Result<Option<UserInfo>> {
|
||||
let user = sqlx::query_as!(
|
||||
User,
|
||||
"SELECT * FROM usr where username = $1 AND workspace_id = $2",
|
||||
User2,
|
||||
"SELECT usr.*, password.super_admin, password.name FROM usr LEFT JOIN password ON usr.email = password.email Where usr.username = $1 AND workspace_id = $2
|
||||
",
|
||||
username,
|
||||
w_id
|
||||
)
|
||||
.fetch_optional(db)
|
||||
.await?;
|
||||
let is_super_admin = sqlx::query_scalar!(
|
||||
"SELECT super_admin FROM password WHERE email = $1",
|
||||
user.as_ref().map(|x| &x.email)
|
||||
)
|
||||
.fetch_optional(db)
|
||||
.await?
|
||||
.unwrap_or(false);
|
||||
let groups = get_groups_for_user(
|
||||
&w_id,
|
||||
username,
|
||||
@@ -1339,8 +1349,9 @@ async fn get_user(w_id: &str, username: &str, db: &DB) -> Result<Option<UserInfo
|
||||
workspace_id: usr.workspace_id,
|
||||
email: usr.email,
|
||||
username: usr.username,
|
||||
name: usr.name,
|
||||
is_admin: usr.is_admin,
|
||||
is_super_admin,
|
||||
is_super_admin: usr.super_admin,
|
||||
created_at: usr.created_at,
|
||||
operator: usr.operator,
|
||||
disabled: usr.disabled,
|
||||
|
||||
@@ -125,6 +125,7 @@
|
||||
email: $userStore?.email,
|
||||
groups: $userStore?.groups,
|
||||
username: $userStore?.username,
|
||||
name: $userStore?.name,
|
||||
query: Object.fromEntries(new URL(window.location.href).searchParams.entries()),
|
||||
hash: window.location.hash.substring(1),
|
||||
workspace: $workspaceStore,
|
||||
|
||||
@@ -6,6 +6,7 @@ import { getLocalSetting } from './utils'
|
||||
|
||||
export interface UserExt {
|
||||
email: string
|
||||
name: string
|
||||
username: string
|
||||
is_admin: boolean
|
||||
is_super_admin: boolean
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
let can_write = false
|
||||
|
||||
async function loadApp() {
|
||||
app = await AppService.getAppLiteByPath({ workspace: $workspaceStore!, path: $page.params.path })
|
||||
app = await AppService.getAppLiteByPath({
|
||||
workspace: $workspaceStore!,
|
||||
path: $page.params.path
|
||||
})
|
||||
can_write = canWrite(app?.path, app?.extra_perms!, $userStore)
|
||||
}
|
||||
|
||||
@@ -48,6 +51,7 @@
|
||||
<AppPreview
|
||||
context={{
|
||||
email: $userStore?.email,
|
||||
name: $userStore?.name,
|
||||
username: $userStore?.username,
|
||||
groups: $userStore?.groups,
|
||||
query: Object.fromEntries($page.url.searchParams.entries()),
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
noBackend={false}
|
||||
context={{
|
||||
email: $userStore?.email,
|
||||
name: $userStore?.name,
|
||||
groups: $userStore?.groups,
|
||||
username: $userStore?.username,
|
||||
query: Object.fromEntries($page.url.searchParams.entries()),
|
||||
|
||||
@@ -147,6 +147,7 @@
|
||||
noBackend={false}
|
||||
context={{
|
||||
email: $userStore?.email,
|
||||
name: $userStore?.name,
|
||||
groups: $userStore?.groups,
|
||||
username: $userStore?.username,
|
||||
query: Object.fromEntries($page.url.searchParams.entries()),
|
||||
|
||||
Reference in New Issue
Block a user