Add username to web app and state api (#50)
This commit is contained in:
1 parent
5baab67bb4
commit
71453237c4
5 files changed
+26
-6
No files matched your search
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
- SponsorBlock notification
|
- SponsorBlock notification
|
||||||
|
- Invidious username to web app v1
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Crash in case GetLocalIpAddress() returns invalid
|
- Crash in case GetLocalIpAddress() returns invalid
|
||||||
|
|||||||
@@ -36,7 +36,13 @@ namespace Http
|
|||||||
' Token is encoded twice for some reason
|
' Token is encoded twice for some reason
|
||||||
token = request.query["token"].DecodeUri().DecodeUriComponent()
|
token = request.query["token"].DecodeUri().DecodeUriComponent()
|
||||||
referer = request.query["ref"].DecodeUri()
|
referer = request.query["ref"].DecodeUri()
|
||||||
InvidiousSettings.SetAuthToken(token, referer)
|
username = request.query["username"]
|
||||||
|
' TODO: remove null check after 6 months of https://github.com/iv-org/invidious/pull/3603
|
||||||
|
if username <> invalid
|
||||||
|
username = username.DecodeUriComponent()
|
||||||
|
end if
|
||||||
|
|
||||||
|
InvidiousSettings.SetAuthToken(token, referer, username)
|
||||||
server.task.top.login = true
|
server.task.top.login = true
|
||||||
end if
|
end if
|
||||||
response.Redirect("/")
|
response.Redirect("/")
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ namespace Http
|
|||||||
selected_instance: InvidiousSettings.GetSelectedInstance(),
|
selected_instance: InvidiousSettings.GetSelectedInstance(),
|
||||||
auth_url: Invidious.GetAuthorizeTokenLink(),
|
auth_url: Invidious.GetAuthorizeTokenLink(),
|
||||||
logged_in: authToken <> invalid,
|
logged_in: authToken <> invalid,
|
||||||
logged_in_instance: authToken <> invalid ? authToken.instance : invalid
|
logged_in_instance: authToken <> invalid ? authToken.instance : invalid,
|
||||||
|
logged_in_username: authToken <> invalid ? authToken.username : invalid
|
||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|||||||
@@ -36,11 +36,16 @@ namespace InvidiousSettings
|
|||||||
return instances[0]
|
return instances[0]
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function SetAuthToken(token as string, instance as string)
|
function SetAuthToken(token as string, instance as string, username as dynamic)
|
||||||
json = FormatJson({
|
obj = {
|
||||||
token: token,
|
token: token,
|
||||||
instance: instance
|
instance: instance
|
||||||
})
|
}
|
||||||
|
if username <> invalid
|
||||||
|
obj.username = username
|
||||||
|
end if
|
||||||
|
|
||||||
|
json = FormatJson(obj)
|
||||||
RegistryUtils.Write(RegistryUtils.INVIDIOUS_TOKEN, json)
|
RegistryUtils.Write(RegistryUtils.INVIDIOUS_TOKEN, json)
|
||||||
|
|
||||||
instances = InvidiousSettings.GetCurrentInstances()
|
instances = InvidiousSettings.GetCurrentInstances()
|
||||||
|
|||||||
@@ -261,7 +261,14 @@ ${JSON.stringify(window.appState.invidious, null, 2)}
|
|||||||
document.getElementById("app-version").innerText = `Version: ${appState.app.version}`
|
document.getElementById("app-version").innerText = `Version: ${appState.app.version}`
|
||||||
|
|
||||||
if (appState.invidious.logged_in) {
|
if (appState.invidious.logged_in) {
|
||||||
document.getElementById("logged-in").innerHTML = `Logged In: true (<a href="${appState.invidious.logged_in_instance}" target="_blank">${appState.invidious.logged_in_instance}</a>)`
|
let loggedIn = 'Logged In '
|
||||||
|
if (appState.invidious.logged_in_username) {
|
||||||
|
loggedIn += `as "${appState.invidious.logged_in_username}"`
|
||||||
|
} else {
|
||||||
|
loggedIn += ": true"
|
||||||
|
}
|
||||||
|
loggedIn += ` (<a href="${appState.invidious.logged_in_instance}" target="_blank">${appState.invidious.logged_in_instance}</a>)`
|
||||||
|
document.getElementById("logged-in").innerHTML = loggedIn
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("logged-in").innerHTML = "Logged In: false"
|
document.getElementById("logged-in").innerHTML = "Logged In: false"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user