From dc31c4bdd7831e9b4ac0f86f842de2a03dd64c45 Mon Sep 17 00:00:00 2001 From: Tobias <118622651+hatobi@users.noreply.github.com> Date: Sat, 2 Nov 2024 16:25:32 +0100 Subject: [PATCH] conditional login logic if username contains "|" the username should be split into email and username. if not, continue as before --- Uberspace.lua | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Uberspace.lua b/Uberspace.lua index 604f2c4..c32e731 100644 --- a/Uberspace.lua +++ b/Uberspace.lua @@ -6,14 +6,14 @@ WebBanking{version = 1.02, url = 'https://dashboard.uberspace.de/login', - services = {'Uberspace.de metauser'}, + services = {'Uberspace.de'}, description = string.format( MM.localizeText("Get balance and transactions for %s"), - "Uberspace.de metauser") + "Uberspace.de") } function SupportsBank (protocol, bankCode) - return bankCode == 'Uberspace.de metauser' and protocol == ProtocolWebBanking + return bankCode == 'Uberspace.de' and protocol == ProtocolWebBanking end local usConnection = Connection() @@ -22,20 +22,24 @@ local usUsername function InitializeSession (protocol, bankCode, username, username2, password, username3) - -- Split the input into email and username based on '|' + -- Check if the username contains '|' local splitPos = username:find("|") - if not splitPos then - return "Failed to log in. Please check that the username includes both email and username separated by '|'." + + if splitPos then + -- If `|` is found, split into email and username + usLogin = username:sub(1, splitPos - 1) + usUsername = username:sub(splitPos + 1) + else + -- If no `|` is found, use the entire value as both email and username + usLogin = username + usUsername = username end - usEmail = username:sub(1, splitPos - 1) - usUsername = username:sub(splitPos + 1) - -- Login. - usUsername = usEmail + usUsername = usLogin html = HTML(usConnection:get('https://dashboard.uberspace.de/login')) - html:xpath('//input[@name="login"]'):attr('value', usEmail) + html:xpath('//input[@name="login"]'):attr('value', usLogin) html:xpath('//input[@name="password"]'):attr('value', password) html = HTML(