Compare commits
2 Commits
51f4770c23
...
2da2075d03
| Author | SHA1 | Date | |
|---|---|---|---|
| 2da2075d03 | |||
| f23392751d |
@@ -66,6 +66,14 @@
|
||||
<a href="/diary/export?format=csv">Download CSV</a>
|
||||
<a href="/diary/export?format=json">Download JSON</a>
|
||||
</section>
|
||||
<section class="profile-manage">
|
||||
<h3>Account</h3>
|
||||
<a href="/settings/profile">Profile settings</a>
|
||||
<a href="/social/blocked">Blocked users</a>
|
||||
{% if ctx.is_admin %}
|
||||
<a href="/admin/blocked-domains">Admin — blocked domains</a>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<div class="view-tabs">
|
||||
|
||||
@@ -14,6 +14,7 @@ pub struct RemoteActorView {
|
||||
pub struct HtmlPageContext {
|
||||
pub user_email: Option<String>,
|
||||
pub user_id: Option<Uuid>,
|
||||
pub is_admin: bool,
|
||||
pub register_enabled: bool,
|
||||
pub rss_url: String,
|
||||
pub page_title: String,
|
||||
|
||||
@@ -46,21 +46,24 @@ pub(crate) async fn build_page_context(
|
||||
csrf_token: String,
|
||||
) -> HtmlPageContext {
|
||||
let uuid = user_id.as_ref().map(|u| u.value());
|
||||
let user_email = if let Some(ref id) = user_id {
|
||||
state
|
||||
let (user_email, is_admin) = if let Some(ref id) = user_id {
|
||||
let user = state
|
||||
.app_ctx
|
||||
.user_repository
|
||||
.find_by_id(id)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|u| u.email().value().to_string())
|
||||
.flatten();
|
||||
let email = user.as_ref().map(|u| u.email().value().to_string());
|
||||
let admin = user.as_ref().map(|u| matches!(u.role(), domain::models::UserRole::Admin)).unwrap_or(false);
|
||||
(email, admin)
|
||||
} else {
|
||||
None
|
||||
(None, false)
|
||||
};
|
||||
HtmlPageContext {
|
||||
user_email,
|
||||
user_id: uuid,
|
||||
is_admin,
|
||||
register_enabled: state.app_ctx.config.allow_registration,
|
||||
rss_url: "/feed.rss".to_string(),
|
||||
page_title: "Movies Diary".to_string(),
|
||||
@@ -104,6 +107,7 @@ pub async fn get_login_page(
|
||||
let ctx = HtmlPageContext {
|
||||
user_email: None,
|
||||
user_id: None,
|
||||
is_admin: false,
|
||||
register_enabled: state.app_ctx.config.allow_registration,
|
||||
rss_url: "/feed.rss".to_string(),
|
||||
page_title: "Login — Movies Diary".to_string(),
|
||||
@@ -170,6 +174,7 @@ pub async fn get_register_page(
|
||||
let ctx = HtmlPageContext {
|
||||
user_email: None,
|
||||
user_id: None,
|
||||
is_admin: false,
|
||||
register_enabled: true,
|
||||
rss_url: "/feed.rss".to_string(),
|
||||
page_title: "Register — Movies Diary".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user