summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2022-08-22 23:43:52 -0300
committerJesusaves <cpntb1@ymail.com>2022-08-22 23:43:52 -0300
commitda56f0b98e195fad096a42c2529639974915f0c9 (patch)
tree2c14c07bb7bbc73249d4aac83edf3f105e94c800
parent2bed6e6368727f41d58e19a20f7665986dfde2bf (diff)
downloadrenpy-da56f0b98e195fad096a42c2529639974915f0c9.tar.gz
renpy-da56f0b98e195fad096a42c2529639974915f0c9.tar.bz2
renpy-da56f0b98e195fad096a42c2529639974915f0c9.tar.xz
renpy-da56f0b98e195fad096a42c2529639974915f0c9.zip
Automatic login: Death to the annoying login screen!
-rw-r--r--game/client.rpy9
-rw-r--r--game/core.rpy2
-rw-r--r--game/screens.rpy7
-rw-r--r--game/update.rpy36
-rw-r--r--game/vault.rpy3
5 files changed, 54 insertions, 3 deletions
diff --git a/game/client.rpy b/game/client.rpy
index 771318f..07325e9 100644
--- a/game/client.rpy
+++ b/game/client.rpy
@@ -32,6 +32,15 @@ init 2 python:
PORT=persistent.serverlist[idx]["Port"]
CMD=handle_client(launch=True)
OPT="-s %s -y evol2 -p %s -S" % (HOST, PORT)
+ #if renpy.variant("steam_deck"):
+ # OPT+=" --fullscreen"
+ #if True: #(CLIENT_NAME in ["manaplus", "manaverse"]):
+ # #OPT+=" -C \"%s\" -ud \"%s/%s\"" % (get_path("config"), get_path("data"), HOST)
+ # #OPT+=" -C \"%s\"" % (get_path("config"))
+ # # TODO: --screenshot-dir
+ # # <option name="screenheight" value="629"/>
+ # # <option name="screenwidth" value="839"/>
+
stdout("%s %s" % (CMD, OPT))
########################################################################
diff --git a/game/core.rpy b/game/core.rpy
index b4bbbf6..c23bb90 100644
--- a/game/core.rpy
+++ b/game/core.rpy
@@ -152,6 +152,8 @@ init -3 python:
persistent.evol2cli = "manaverse"
if (persistent.iconify is None):
persistent.iconify = ifte(renpy.windows, False, True)
+ if (persistent.autologin is None):
+ persistent.autologin = True
#############################################################################
## Conditional imports
diff --git a/game/screens.rpy b/game/screens.rpy
index 0ea46e1..0a2f35c 100644
--- a/game/screens.rpy
+++ b/game/screens.rpy
@@ -704,10 +704,10 @@ screen preferences():
if persistent.hello is not None:
null height 20
label _("Others")
- showif not persistent.steam:
+ showif not persistent.steam and not persistent.autologin:
textbutton _("Remember TOTP %s" % ifte(persistent.totp is not None, _("ON"), _("OFF"))):
action Function(renpy.call_in_new_context, "set2fa")
- showif not persistent.steam:
+ showif not persistent.steam and not persistent.autologin:
textbutton _("Remember Mail %s" % ifte(
persistent.email is not None, _("ON"), _("OFF"))):
action Function(renpy.call_in_new_context, "resetm")
@@ -717,6 +717,9 @@ screen preferences():
textbutton "{size=20}"+_("Reset Login Method")+"{/size}":
action Function(renpy.call_in_new_context, "savevm")
null height 12
+ showif not persistent.steam:
+ textbutton _("Auto-Login %s" % ifte(persistent.autologin is not None, _("ON"), _("OFF"))):
+ action ToggleVariable("persistent.autologin")
textbutton _("Check Updates"):
action ifte(persistent.evol2cli is not None and
persistent.host is not None and
diff --git a/game/update.rpy b/game/update.rpy
index 8815ebf..7e643d4 100644
--- a/game/update.rpy
+++ b/game/update.rpy
@@ -373,6 +373,37 @@ screen notice(prompt):
label register:
$ status_update(" ", 80)
+ # Automatic login
+ if persistent.autologin and persistent.email and persistent.passd and persistent.totp:
+ python:
+ print("Automatic login ON")
+ key = base64.b32decode(persistent.totp.encode('utf-8'), True)
+ msg = struct.pack(">Q", int(time.time()/30))
+ h = hmac.new(key, msg, hashlib.sha1).digest()
+ if LEGACY:
+ o = ord(h[19]) & 15
+ else:
+ o = (h[19] & 15)
+ _return = (struct.unpack(">I", h[o:o+4])[0] & 0x7fffffff) % 1000000
+ _return = "%06d" % _return
+ print("TOTP: %s" % _return)
+ del key, msg, h, o
+ if LEGACY:
+ password = str(bytearray((x ^ int(persistent.rhash/mp.sub) for x in bytearray(persistent.passd, 'utf-8'))))
+ else:
+ password = bytearray((x ^ int(persistent.rhash/mp.sub) for x in persistent.passd)).decode('utf-8')
+ code2FA = _return
+ data = {"mail": persistent.email,
+ "pass": password,
+ "totp": code2FA[:6]
+ }
+ r = vault.post(VAULT_HOST+"/user_auth", json=data)
+ del password, data
+ # Python end
+ if (r.status_code != 200):
+ call screen notice(_("Vault returned error %d\n\nAutomatic login failed." % r.status_code))
+
+ # Manual login
if persistent.vmethod is None:
call screen register_method
$ persistent.vmethod = _return
@@ -443,7 +474,10 @@ label register:
key = base64.b32decode(persistent.totp.encode('utf-8'), True)
msg = struct.pack(">Q", int(time.time()/30))
h = hmac.new(key, msg, hashlib.sha1).digest()
- o = ord(h[19]) & 15
+ if LEGACY:
+ o = ord(h[19]) & 15
+ else:
+ o = (h[19] & 15)
_return = (struct.unpack(">I", h[o:o+4])[0] & 0x7fffffff) % 1000000
_return = "%06d" % _return
print("TOTP: %s" % _return)
diff --git a/game/vault.rpy b/game/vault.rpy
index bbe9fc3..f3ddc38 100644
--- a/game/vault.rpy
+++ b/game/vault.rpy
@@ -241,6 +241,9 @@ label register_vault:
status_update("Creating account and logging in...")
renpy.notify("Account created! Check email.")
time.sleep(1.0)
+ # Attempt to save the TOTP credential (DISCOURAGED)
+ if persistent.autologin and "totp" in auth2.keys():
+ persistent.totp = auth2["totp"].split("secret=")[1].split("&")[0]
except:
pass