From 4eb4b00271baf784fb4ac14f0c4a307ff76b02a4 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 31 Mar 2025 14:15:06 -0400 Subject: [PATCH] only do a partial auto login, when logging in via NG or via saved session --- .../funkin/api/newgrounds/NewgroundsClient.hx | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/source/funkin/api/newgrounds/NewgroundsClient.hx b/source/funkin/api/newgrounds/NewgroundsClient.hx index 245b1f2dd..2dff97f80 100644 --- a/source/funkin/api/newgrounds/NewgroundsClient.hx +++ b/source/funkin/api/newgrounds/NewgroundsClient.hx @@ -72,7 +72,7 @@ class NewgroundsClient #if FEATURE_NEWGROUNDS_AUTOLOGIN // Attempt an automatic login. trace('[NEWGROUNDS] Attempting new login immediately!'); - this.login(); + this.autoLogin(); #else trace('[NEWGROUNDS] Not logged in, you have to login manually!'); #end @@ -102,6 +102,32 @@ class NewgroundsClient } } + public function autoLogin(?onSuccess:Void->Void, ?onError:Void->Void):Void + { + if (NG.core == null) + { + FlxG.log.warn("No Newgrounds client initialized! Are your credentials invalid?"); + return; + } + + var dummyPassport:String->Void = function(_) { + // just a dummy passport, so we don't create a popup + // otherwise `NG.core.requestLogin()` will automatically attempt to open a tab at the beginning of the game + // users should go to the Options Menu to login to NG + // we cancel the request, so we can call it later + NG.core.cancelLoginRequest(); + }; + + if (onSuccess != null && onError != null) + { + NG.core.requestLogin(onLoginResolvedWithCallbacks.bind(_, onSuccess, onError), dummyPassport); + } + else + { + NG.core.requestLogin(onLoginResolved, dummyPassport); + } + } + /** * Log out of Newgrounds and invalidate the current session. * @param onSuccess An optional callback for when the logout is successful.