mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 17:08:13 +00:00
more permissions
This commit is contained in:
1 parent
7d1d1c1791
commit
5cee2f4c5e
3 files changed
+40
-4
No files matched your search
@@ -122,15 +122,15 @@ CREATE TABLE user_roles (
|
||||
-- Usage
|
||||
can_use_tts BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_use_w2l BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_delete_own_tts_results BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_delete_own_w2l_results BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_delete_own_account BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
-- Contribution
|
||||
can_upload_tts_models BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_upload_w2l_templates BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_delete_own_tts_models BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_delete_own_tts_results BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_delete_own_w2l_templates BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_delete_own_w2l_results BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_delete_own_account BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
-- Moderation
|
||||
can_approve_w2l_templates BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
@@ -34,6 +34,9 @@ pub struct UserInfo {
|
||||
// Usage permissions:
|
||||
pub can_use_tts: bool,
|
||||
pub can_use_w2l: bool,
|
||||
pub can_delete_own_tts_results: bool,
|
||||
pub can_delete_own_w2l_results: bool,
|
||||
pub can_delete_own_account: bool,
|
||||
|
||||
// Contribution permissions:
|
||||
pub can_upload_tts_models: bool,
|
||||
@@ -47,8 +50,11 @@ pub struct UserInfo {
|
||||
pub can_edit_other_users_tts_models: bool,
|
||||
pub can_edit_other_users_w2l_templates: bool,
|
||||
pub can_delete_other_users_tts_models: bool,
|
||||
pub can_delete_other_users_tts_results: bool,
|
||||
pub can_delete_other_users_w2l_templates: bool,
|
||||
pub can_delete_other_users_w2l_results: bool,
|
||||
pub can_ban_users: bool,
|
||||
pub can_delete_users: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -126,6 +132,9 @@ pub async fn session_info_handler(
|
||||
// Usage permissions:
|
||||
can_use_tts: session_data.can_use_tts,
|
||||
can_use_w2l: session_data.can_use_w2l,
|
||||
can_delete_own_tts_results: session_data.can_delete_own_tts_results,
|
||||
can_delete_own_w2l_results: session_data.can_delete_own_w2l_results,
|
||||
can_delete_own_account: session_data.can_delete_own_account,
|
||||
|
||||
// Contribution permissions:
|
||||
can_upload_tts_models: session_data.can_upload_tts_models,
|
||||
@@ -139,8 +148,11 @@ pub async fn session_info_handler(
|
||||
can_edit_other_users_tts_models: session_data.can_edit_other_users_tts_models,
|
||||
can_edit_other_users_w2l_templates: session_data.can_edit_other_users_w2l_templates,
|
||||
can_delete_other_users_tts_models: session_data.can_delete_other_users_tts_models,
|
||||
can_delete_other_users_tts_results: session_data.can_delete_other_users_tts_results,
|
||||
can_delete_other_users_w2l_templates: session_data.can_delete_other_users_w2l_templates,
|
||||
can_delete_other_users_w2l_results: session_data.can_delete_other_users_w2l_results,
|
||||
can_ban_users: session_data.can_ban_users,
|
||||
can_delete_users: session_data.can_delete_users,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ pub struct SessionUserRecord {
|
||||
// Usage
|
||||
pub can_use_tts: bool,
|
||||
pub can_use_w2l: bool,
|
||||
pub can_delete_own_tts_results: bool,
|
||||
pub can_delete_own_w2l_results: bool,
|
||||
pub can_delete_own_account: bool,
|
||||
|
||||
// Contribution
|
||||
pub can_upload_tts_models: bool,
|
||||
@@ -59,8 +62,11 @@ pub struct SessionUserRecord {
|
||||
pub can_edit_other_users_tts_models: bool,
|
||||
pub can_edit_other_users_w2l_templates: bool,
|
||||
pub can_delete_other_users_tts_models: bool,
|
||||
pub can_delete_other_users_tts_results: bool,
|
||||
pub can_delete_other_users_w2l_templates: bool,
|
||||
pub can_delete_other_users_w2l_results: bool,
|
||||
pub can_ban_users: bool,
|
||||
pub can_delete_users: bool,
|
||||
}
|
||||
|
||||
pub struct SessionUserRawDbRecord {
|
||||
@@ -88,6 +94,9 @@ pub struct SessionUserRawDbRecord {
|
||||
// Usage
|
||||
pub can_use_tts: Option<i8>,
|
||||
pub can_use_w2l: Option<i8>,
|
||||
pub can_delete_own_tts_results: Option<i8>,
|
||||
pub can_delete_own_w2l_results: Option<i8>,
|
||||
pub can_delete_own_account: Option<i8>,
|
||||
|
||||
// Contribution
|
||||
pub can_upload_tts_models: Option<i8>,
|
||||
@@ -101,8 +110,11 @@ pub struct SessionUserRawDbRecord {
|
||||
pub can_edit_other_users_tts_models: Option<i8>,
|
||||
pub can_edit_other_users_w2l_templates: Option<i8>,
|
||||
pub can_delete_other_users_tts_models: Option<i8>,
|
||||
pub can_delete_other_users_tts_results: Option<i8>,
|
||||
pub can_delete_other_users_w2l_templates: Option<i8>,
|
||||
pub can_delete_other_users_w2l_results: Option<i8>,
|
||||
pub can_ban_users: Option<i8>,
|
||||
pub can_delete_users: Option<i8>,
|
||||
}
|
||||
|
||||
impl SessionChecker {
|
||||
@@ -192,6 +204,9 @@ SELECT
|
||||
|
||||
user_roles.can_use_tts,
|
||||
user_roles.can_use_w2l,
|
||||
user_roles.can_delete_own_tts_results,
|
||||
user_roles.can_delete_own_w2l_results,
|
||||
user_roles.can_delete_own_account,
|
||||
|
||||
user_roles.can_upload_tts_models,
|
||||
user_roles.can_upload_w2l_templates,
|
||||
@@ -203,8 +218,11 @@ SELECT
|
||||
user_roles.can_edit_other_users_tts_models,
|
||||
user_roles.can_edit_other_users_w2l_templates,
|
||||
user_roles.can_delete_other_users_tts_models,
|
||||
user_roles.can_delete_other_users_tts_results,
|
||||
user_roles.can_delete_other_users_w2l_templates,
|
||||
user_roles.can_ban_users
|
||||
user_roles.can_delete_other_users_w2l_results,
|
||||
user_roles.can_ban_users,
|
||||
user_roles.can_delete_users
|
||||
|
||||
FROM users
|
||||
LEFT OUTER JOIN user_sessions
|
||||
@@ -244,6 +262,9 @@ WHERE user_sessions.token = ?
|
||||
// Usage
|
||||
can_use_tts: convert_optional_db_bool_default_false(raw_user_record.can_use_tts),
|
||||
can_use_w2l: convert_optional_db_bool_default_false(raw_user_record.can_use_w2l),
|
||||
can_delete_own_tts_results: convert_optional_db_bool_default_false(raw_user_record.can_delete_own_tts_results),
|
||||
can_delete_own_w2l_results: convert_optional_db_bool_default_false(raw_user_record.can_delete_own_w2l_results),
|
||||
can_delete_own_account: convert_optional_db_bool_default_false(raw_user_record.can_delete_own_account),
|
||||
// Contribution
|
||||
can_upload_tts_models: convert_optional_db_bool_default_false(raw_user_record.can_upload_tts_models),
|
||||
can_upload_w2l_templates: convert_optional_db_bool_default_false(raw_user_record.can_upload_w2l_templates),
|
||||
@@ -255,8 +276,11 @@ WHERE user_sessions.token = ?
|
||||
can_edit_other_users_tts_models: convert_optional_db_bool_default_false(raw_user_record.can_edit_other_users_tts_models),
|
||||
can_edit_other_users_w2l_templates: convert_optional_db_bool_default_false(raw_user_record.can_edit_other_users_w2l_templates),
|
||||
can_delete_other_users_tts_models: convert_optional_db_bool_default_false(raw_user_record.can_delete_other_users_tts_models),
|
||||
can_delete_other_users_tts_results: convert_optional_db_bool_default_false(raw_user_record.can_delete_other_users_tts_results),
|
||||
can_delete_other_users_w2l_templates: convert_optional_db_bool_default_false(raw_user_record.can_delete_other_users_w2l_templates),
|
||||
can_delete_other_users_w2l_results: convert_optional_db_bool_default_false(raw_user_record.can_delete_other_users_w2l_results),
|
||||
can_ban_users: convert_optional_db_bool_default_false(raw_user_record.can_ban_users),
|
||||
can_delete_users: convert_optional_db_bool_default_false(raw_user_record.can_delete_users) ,
|
||||
};
|
||||
|
||||
Ok(Some(result_user_record))
|
||||
|
||||
Reference in new issue
Block a user