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
@@ -36,7 +36,13 @@ namespace Http
|
||||
' Token is encoded twice for some reason
|
||||
token = request.query["token"].DecodeUri().DecodeUriComponent()
|
||||
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
|
||||
end if
|
||||
response.Redirect("/")
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace Http
|
||||
selected_instance: InvidiousSettings.GetSelectedInstance(),
|
||||
auth_url: Invidious.GetAuthorizeTokenLink(),
|
||||
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
|
||||
|
||||
|
||||
@@ -36,11 +36,16 @@ namespace InvidiousSettings
|
||||
return instances[0]
|
||||
end function
|
||||
|
||||
function SetAuthToken(token as string, instance as string)
|
||||
json = FormatJson({
|
||||
function SetAuthToken(token as string, instance as string, username as dynamic)
|
||||
obj = {
|
||||
token: token,
|
||||
instance: instance
|
||||
})
|
||||
}
|
||||
if username <> invalid
|
||||
obj.username = username
|
||||
end if
|
||||
|
||||
json = FormatJson(obj)
|
||||
RegistryUtils.Write(RegistryUtils.INVIDIOUS_TOKEN, json)
|
||||
|
||||
instances = InvidiousSettings.GetCurrentInstances()
|
||||
|
||||
Reference in new issue
Block a user