aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/ui
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-01-30 16:34:38 +0100
committermetamuffin <metamuffin@disroot.org>2024-01-30 16:34:38 +0100
commitef88eba498d0362137bcc9203a4cf1a20b6dec9e (patch)
treebd1e6ce50d5f591b722ed12459a116a0b0aff883 /server/src/routes/ui
parent81326d9178a04814c0c8ed669bdf2f19fc865fbe (diff)
downloadjellything-ef88eba498d0362137bcc9203a4cf1a20b6dec9e.tar
jellything-ef88eba498d0362137bcc9203a4cf1a20b6dec9e.tar.bz2
jellything-ef88eba498d0362137bcc9203a4cf1a20b6dec9e.tar.zst
np: authentificate native
Diffstat (limited to 'server/src/routes/ui')
-rw-r--r--server/src/routes/ui/account/settings.rs11
-rw-r--r--server/src/routes/ui/player.rs9
2 files changed, 17 insertions, 3 deletions
diff --git a/server/src/routes/ui/account/settings.rs b/server/src/routes/ui/account/settings.rs
index e91bec0..ec92ba2 100644
--- a/server/src/routes/ui/account/settings.rs
+++ b/server/src/routes/ui/account/settings.rs
@@ -36,6 +36,7 @@ pub struct SettingsForm {
display_name: Option<String>,
theme: Option<Theme>,
player_preference: Option<PlayerKind>,
+ native_secret: Option<String>,
}
fn option_len<'v>(value: &Option<String>, range: Range<usize>) -> form::Result<'v, ()> {
@@ -90,6 +91,12 @@ fn settings_page(session: Session, flash: Option<MyResult<String>>) -> DynLayout
}
input[type="submit", value="Apply"];
}
+ form[method="POST", action=uri!(r_account_settings_post())] {
+ label[for="native_secret"] { "Native Secret" }
+ input[type="password", id="native_secret", name="native_secret"];
+ input[type="submit", value="Update"];
+ p { "The secret can be found in " code{"$XDG_CONFIG_HOME/jellynative_secret"} " or by clicking " a.button[href="jellynative://show-secret"] { "Show Secret" } "." }
+ }
},
..Default::default()
}
@@ -151,6 +158,10 @@ pub fn r_account_settings_post(
user.player_preference = player_preference;
out += "Player preference changed.\n";
}
+ if let Some(native_secret) = &form.native_secret {
+ user.native_secret = native_secret.to_owned();
+ out += "Native secret updated.\n";
+ }
users.insert(&*session.user.name, Ser(user))?;
drop(users);
diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs
index be40d4c..becda91 100644
--- a/server/src/routes/ui/player.rs
+++ b/server/src/routes/ui/player.rs
@@ -46,9 +46,9 @@ impl PlayerConfig {
}
}
-fn jellynative_url(action: &str, node: &str) -> String {
+fn jellynative_url(action: &str, secret: &str, node: &str) -> String {
format!(
- "jellynative://{action}/http://{}{}",
+ "jellynative://{action}/{secret}/http://{}{}",
CONF.hostname,
uri!(r_stream(
node,
@@ -72,12 +72,15 @@ pub fn r_player<'a>(
PlayerKind::Browser => (),
PlayerKind::Native => {
return Ok(Either::Right(Redirect::temporary(jellynative_url(
- "player", id,
+ "player",
+ &sess.user.native_secret,
+ id,
))))
}
PlayerKind::NativeFullscreen => {
return Ok(Either::Right(Redirect::temporary(jellynative_url(
"player-fullscreen",
+ &sess.user.native_secret,
id,
))))
}