Auth state for web app
This commit is contained in:
1 parent
a134e1f50e
commit
00361d5507
6 files changed
+38
-11
No files matched your search
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Fixed
|
||||
|
||||
- Wrong SponsorBlock in the trackbar due to image caching
|
||||
- Expired profile sessions were not marked in web app
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -173,6 +173,7 @@ function GetProfilesDto(includeAccessToken as boolean) as object
|
||||
"serverUrl": profileNode.serverUrl
|
||||
"thumbnail": profileNode.thumbnail
|
||||
"color": color
|
||||
"authState": profileNode.authState
|
||||
}
|
||||
|
||||
if includeAccessToken
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
export let navbar = false;
|
||||
export let selected = false;
|
||||
import UserIcon from "assets/user.svg.svelte";
|
||||
import { playletStateStore } from "lib/Stores";
|
||||
import { playletStateStore, translate } from "lib/Stores";
|
||||
import { ProfileAuthState } from "lib/Types";
|
||||
|
||||
let currentProfile = profile;
|
||||
|
||||
@@ -15,20 +16,20 @@
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
$: needsReauth = currentProfile?.authState === ProfileAuthState.NeedsReauth;
|
||||
$: outlineClass = navbar
|
||||
? `border-2 ${needsReauth ? "border-warning" : "border-primary"}`
|
||||
: `ring ring-offset-base-100 ring-offset-2 ${
|
||||
needsReauth ? "ring-warning" : selected ? "ring-primary" : ""
|
||||
}`;
|
||||
</script>
|
||||
|
||||
{#if currentProfile && currentProfile.username}
|
||||
<div class={`avatar ${navbar ? "w-8 h-8 m-1" : "w-12 h-12"}`}>
|
||||
<div
|
||||
class={`rounded-full flex items-center justify-center w-full h-full
|
||||
${
|
||||
navbar
|
||||
? "border-2 border-primary"
|
||||
: selected
|
||||
? "ring ring-primary ring-offset-base-100 ring-offset-2"
|
||||
: "ring ring-offset-base-100 ring-offset-2"
|
||||
}
|
||||
`}
|
||||
class={`rounded-full flex items-center justify-center w-full h-full ${outlineClass}`}
|
||||
title={needsReauth ? $translate("Session expired") : ""}
|
||||
style="background-color: {currentProfile.color};"
|
||||
>
|
||||
{#if currentProfile.type === "youtube" && currentProfile.thumbnail}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { PlayletApi } from "./Api/PlayletApi";
|
||||
import { get } from "svelte/store";
|
||||
import ProfileAvatar from "./ProfileAvatar.svelte";
|
||||
import { ProfileAuthState } from "lib/Types";
|
||||
|
||||
export function show() {
|
||||
modal.showModal();
|
||||
@@ -118,9 +119,21 @@
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
{#if profile.authState === ProfileAuthState.NeedsReauth}
|
||||
<div class="badge badge-warning badge-sm mt-1">
|
||||
{$translate("Session expired")}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse-content">
|
||||
{#if profile.authState === ProfileAuthState.NeedsReauth}
|
||||
<div class="text-sm mb-2">
|
||||
{$translate(
|
||||
"The session has expired. Please sign in again with this profile, or switch to another profile."
|
||||
)}
|
||||
</div>
|
||||
{/if}
|
||||
{#if profile.id !== currentProfile?.id}
|
||||
<button
|
||||
on:click={() => activate(profile.id)}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
export const ScreenNames = ["search", "home", "bookmarks", "settings", "info", "remote"] as const;
|
||||
|
||||
export enum ProfileAuthState {
|
||||
Authenticated = "Authenticated",
|
||||
NeedsReauth = "NeedsReauth",
|
||||
}
|
||||
|
||||
export type AppState = {
|
||||
screen: "search" | "home" | "bookmarks" | "settings" | "info" | "remote"
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import VideoCell from "./VideoCell.svelte";
|
||||
import PlaylistCell from "./PlaylistCell.svelte";
|
||||
import ChannelCell from "./ChannelCell.svelte";
|
||||
import { ProfileAuthState } from "lib/Types";
|
||||
|
||||
// TODO:P1 figure out why some uncached feeds (e.g. channels/ucid/videos) get hit twice
|
||||
export let feed: any = undefined;
|
||||
@@ -92,7 +93,12 @@
|
||||
userCountryCode = "US";
|
||||
}
|
||||
invidiousApi.userCountryCode = userCountryCode;
|
||||
invidiousApi.isLoggedIn = !!(value.profiles?.currentProfile ?? false);
|
||||
const currentProfile = (value.profiles?.profiles ?? []).find(
|
||||
(p) => p.id === value.profiles?.currentProfile
|
||||
);
|
||||
invidiousApi.isLoggedIn =
|
||||
!!currentProfile &&
|
||||
currentProfile.authState !== ProfileAuthState.NeedsReauth;
|
||||
loadRow();
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user