summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2023-06-26 10:04:27 -0300
committerJesusaves <cpntb1@ymail.com>2023-06-26 10:04:27 -0300
commit35ab1e1c02dcf5e521ee64a5b062612131f6c409 (patch)
treebf472e984389d262c168f8d2dd266d4b4693f3e1
parentce8826c06244f45492d2e8b135e388e63339b825 (diff)
downloadrenpy-35ab1e1c02dcf5e521ee64a5b062612131f6c409.tar.gz
renpy-35ab1e1c02dcf5e521ee64a5b062612131f6c409.tar.bz2
renpy-35ab1e1c02dcf5e521ee64a5b062612131f6c409.tar.xz
renpy-35ab1e1c02dcf5e521ee64a5b062612131f6c409.zip
Account linking and unlinking. Tested on Moubootaur Legends only.
-rw-r--r--game/soul.rpy149
1 files changed, 147 insertions, 2 deletions
diff --git a/game/soul.rpy b/game/soul.rpy
index f4d583e..96ec8d3 100644
--- a/game/soul.rpy
+++ b/game/soul.rpy
@@ -37,6 +37,67 @@ screen soulmsg(smessage):
#################################################################################
+screen soul_linking(smessage):
+ zorder 100
+ if mySoul is not None:
+ fixed:
+ frame:
+ background Frame("images/default.png", 0, 0)
+ xalign 0.5
+ yalign 0.5
+ xminimum 0.85
+ xmaximum 0.85
+ yminimum 0.8
+ ymaximum 0.8
+ label "{color=#FFF}%s{/color}" % smessage:
+ xalign 0.5
+ yalign 0.0
+ vbox:
+ xalign 0.1
+ yalign 0.5
+ hbox:
+ label _("Email: ")
+ $ input=Input(
+ value=UEditorInputValue("mail", "a@a.com", "str"),
+ copypaste=True,
+ allow="qwertyuiopasdfghjklçzxcvbnm QWERTYUIOPASDFGHJKLÇZXCVBNM1234567890-+=!(),.:;@_",
+ length=52)
+ button:
+ #key_events True
+ action input.enable
+ add input
+ hbox:
+ spacing 10
+ label _("Username: ")
+ # For some reason, we don't accept all ascii special codes
+ # WARNING: Non-ascii will break the hashing.
+ $ input=Input(
+ value=UEditorInputValue("pasd", "user", "str"),
+ copypaste=True,
+ allow="qwertyuiopasdfghjklçzxcvbnm QWERTYUIOPASDFGHJKLÇZXCVBNM1234567890-+=!(),.:;@*^_|",
+ length=52)
+ button:
+ #key_events True
+ action input.enable
+ add input
+ frame:
+ yalign 0.9
+ xalign 0.9
+ xmaximum 240
+ button:
+ xmaximum 240
+ ymaximum 40
+ action Return(None)
+ fixed:
+ #add Frame("gui/button/choice_hover_background.png", 0, 0)
+ text _("OK »"):
+ color "#000"
+ xalign 0.5
+ yalign 0.5
+
+
+
+#################################################################################
screen souldata():
zorder 100
if mySoul is not None:
@@ -338,6 +399,7 @@ label managevault:
$ _arg = _return[1]
if _cmd is None:
$ vault_loop = False
+ #####################################################################
elif _cmd == "2fa":
call screen soulmsg(_("{b}Two Factor Authentication{/b}\n\nIf you have two factor authentication enabled, it'll be disabled.\nIf it is disabled, it'll be enabled, and you'll receive an {b}email{/b} with instructions to generate TOTP tokens.\n\nIf enabled, you will not be able to login without the authentication token."))
call screen confirm(_("{b}Two Factor Authentication{/b}\n\nAre you sure you want to change this setting?"), [SetVariable("_arg", True), Return()], [SetVariable("_arg", False), Return()])
@@ -361,11 +423,94 @@ label managevault:
call screen soulmsg(_("You are being rate-limited, and the change was not possible. Please wait a minute before trying again."))
else:
call screen soulmsg(_("An internal error happened, please report (code: %d)" % r.status_code))
+ #####################################################################
elif _cmd == "link":
- call screen soulmsg(_("Currently, you cannot link external accounts. Keep in mind that if you already have an account, nothing will happen."))
+ $ world = _arg["UUID"]
+ ## A mail will be sent with a link to complete linking
+ $ uedit["mail"] = ""
+ $ uedit["pasd"] = ""
+ call screen soul_linking(_("{b}External Account Linking{/b}\n\n{size=-3}Use this if you used an account with ManaVerse or ManaPlus previously, and want to use it with the Mana Launcher. Keep in mind that if you already have an account with the Launcher, nothing will happen. Both the launcher and the game account must have valid email addresses, but they don't need to be the same. Once linked, you'll no longer be able to login using ManaPlus or ManaVerse directly. The home world account cannot be (un)linked from the Vault. Once done, you'll receive an email with further instructions. To cancel, empty any of the fields.{/size}"))
+ #call screen notice(_("Sorry, not yet implemented!\n\nMail: %s\nUser: %s\nWorld: %s" % (uedit["mail"], uedit["pasd"], world)))
+ #call screen soulmsg(_("Currently, you cannot link external accounts. Keep in mind that if you already have an account, nothing will happen."))
+ python:
+ sCode=400
+ try:
+ assert len(uedit["mail"]) > 4
+ assert len(uedit["pasd"]) > 4
+ assert "@" in uedit["mail"]
+ auth = {"vaultId": vaultId,
+ "token": vaultToken,
+ "totp": calcOTP(vaultOTP),
+ "world": world,
+ "email": uedit["mail"],
+ "user": uedit["pasd"]}
+
+ ## Make the POST request
+ r=vault.post(VAULT_HOST+"/link", json=auth, timeout=15.0)
+ ## Parse status codes and show proper notice
+ sCode = r.status_code
+ except:
+ sCode=502
+ traceback.print_exc()
+ if sCode == 200:
+ call screen soulmsg(_("A link was sent to your email.\n\nPlease follow it before trying to access the world in the Launcher.\nIf you don't, THEN LINKING WILL BE RENDERED IMPOSSIBLE.\n\nAfter a successful linking, an Error Response 200 OK will be shown on your browser."))
+ elif sCode == 400:
+ call screen soulmsg(_("An error on the client happened and the request was rejected. Are you logged in, and using the latest version?"))
+ elif sCode == 403:
+ call screen soulmsg(_("You are not authorized to perform this operation. Please try again later, in three minutes."))
+ elif sCode == 404:
+ call screen soulmsg(_("To prevent cheating, you cannot link nor unlink your home world. Please contact staff."))
+ elif sCode == 429:
+ call screen soulmsg(_("You are being rate-limited, and the change was not possible. Please wait a minute before trying again."))
+ else:
+ call screen soulmsg(_("An internal error happened, please report (code: %d)" % sCode))
+ $ del sCode
+ $ uedit["mail"] = ""
+ $ uedit["pasd"] = ""
pass
+ #####################################################################
elif _cmd == "unlink":
- call screen soulmsg(_("Currently, you cannot unlink accounts. Keep in mind that if you do not have an account, nothing will happen."))
+ $ world = _arg["UUID"]
+ $ uedit["mail"] = ""
+ $ uedit["pasd"] = ""
+ call screen soul_linking(_("{b}World Account Unlinking{/b}\n\n{size=-3}This allows you to unlink a game account from your Vault account. Keep in mind that if you do not have an account with the Launcher, nothing will happen. Once unlinked, a new password will be made and sent to the supplied email. You must agree to the {a=%s}Terms of Service{/a}. To cancel, empty any of the fields.{/size}" % (_arg["Policy"])))
+ #call screen notice(_("Sorry, not yet implemented!\n\nMail: %s\nUser: %s\nWorld: %s" % (uedit["mail"], uedit["pasd"], world)))
+ #call screen soulmsg(_("Currently, you cannot unlink accounts. Keep in mind that if you do not have an account, nothing will happen."))
+ python:
+ sCode=400
+ try:
+ assert len(uedit["mail"]) > 4
+ assert len(uedit["pasd"]) > 4
+ assert "@" in uedit["mail"]
+ auth = {"vaultId": vaultId,
+ "token": vaultToken,
+ "totp": calcOTP(vaultOTP),
+ "world": world,
+ "email": uedit["mail"],
+ "user": uedit["pasd"]}
+
+ ## Make the POST request
+ r=vault.post(VAULT_HOST+"/unlink", json=auth, timeout=15.0)
+ ## Parse status codes and show proper notice
+ sCode = r.status_code
+ except:
+ sCode=502
+ traceback.print_exc()
+ if sCode == 200:
+ call screen soulmsg(_("A link was sent to your email.\n\nPlease follow it before trying to access the world in the Launcher.\nIf you don't, THEN LINKING WILL BE RENDERED IMPOSSIBLE.\n\nAfter a successful linking, an Error Response 200 OK will be shown on your browser."))
+ elif sCode == 400:
+ call screen soulmsg(_("An error on the client happened and the request was rejected. Are you logged in, and using the latest version?"))
+ elif sCode == 403:
+ call screen soulmsg(_("You are not authorized to perform this operation. Please try again later, in three minutes."))
+ elif sCode == 404:
+ call screen soulmsg(_("To prevent cheating, you cannot link nor unlink your home world. Please contact staff."))
+ elif sCode == 429:
+ call screen soulmsg(_("You are being rate-limited, and the change was not possible. Please wait a minute before trying again."))
+ else:
+ call screen soulmsg(_("An internal error happened, please report (code: %d)" % sCode))
+ $ del sCode
+ $ uedit["mail"] = ""
+ $ uedit["pasd"] = ""
pass
else:
$ stdout("%s unrecognized" % _cmd)