diff --git a/Headers/Utils.h b/Headers/Utils.h index 0b1fb2f..615755d 100644 --- a/Headers/Utils.h +++ b/Headers/Utils.h @@ -3,4 +3,4 @@ NSURL *getPyoncordDirectory(void); UIColor *hexToUIColor(NSString *hex); -void showErrorAlert(NSString *title, NSString *message); \ No newline at end of file +void showErrorAlert(NSString *title, NSString *message, void (^completion)(void)); \ No newline at end of file diff --git a/Sources/Sideloading.x b/Sources/Sideloading.x index 8a2a380..45121e7 100644 --- a/Sources/Sideloading.x +++ b/Sources/Sideloading.x @@ -1,5 +1,6 @@ #import "Logger.h" #import "Utils.h" +#import #import #import #import @@ -18,14 +19,31 @@ extern OSStatus CMSDecoderCopyContent(CMSDecoderRef cmsDecoder, CFDataRef *conte typedef NS_ENUM(NSInteger, BundleIDError) { BundleIDErrorFiles, - BundleIDErrorIcon + BundleIDErrorIcon, + BundleIDErrorPasskey }; static void showBundleIDError(BundleIDError error) { - NSString *message = @"For this to work change the Bundle ID so that it matches your " - @"provisioning profile's App ID (excluding the Team ID prefix)."; - NSString *title = error == BundleIDErrorFiles ? @"Cannot Access Files" : @"Cannot Change Icon"; - showErrorAlert(title, message); + NSString *message; + NSString *title; + void (^completion)(void) = nil; + + switch (error) { + case BundleIDErrorFiles: + case BundleIDErrorIcon: + message = @"For this to work change the Bundle ID so that it matches your " + @"provisioning profile's App ID (excluding the Team ID prefix)."; + title = error == BundleIDErrorFiles ? @"Cannot Access Files" : @"Cannot Change Icon"; + break; + case BundleIDErrorPasskey: + message = @"Passkeys are not supported when sideloading Discord. " + @"Please use a different login method."; + title = @"Cannot Use Passkey"; + completion = ^{ exit(0); }; + break; + } + + showErrorAlert(title, message, completion); } static NSString *getProvisioningAppID(void) { @@ -180,6 +198,14 @@ static BOOL isSelfCall(void) { } %end +%hook ASAuthorizationController + +- (void)performRequests { + showBundleIDError(BundleIDErrorPasskey); +} + +%end + %end %ctor { diff --git a/Sources/Tweak.x b/Sources/Tweak.x index e8a1287..c0df699 100644 --- a/Sources/Tweak.x +++ b/Sources/Tweak.x @@ -23,7 +23,7 @@ static LoaderConfig *loaderConfig; if (!bunnyPatchesBundle) { BunnyLog(@"Failed to load BunnyPatches bundle from path: %@", bunnyPatchesBundlePath); showErrorAlert(@"Loader Error", - @"Failed to initialize mod loader. Please reinstall the tweak."); + @"Failed to initialize mod loader. Please reinstall the tweak.", nil); return %orig; } @@ -31,7 +31,7 @@ static LoaderConfig *loaderConfig; if (!patchPath) { BunnyLog(@"Failed to find payload-base.js in bundle"); showErrorAlert(@"Loader Error", - @"Failed to initialize mod loader. Please reinstall the tweak."); + @"Failed to initialize mod loader. Please reinstall the tweak.", nil); return %orig; } diff --git a/Sources/Utils.m b/Sources/Utils.m index bf4d274..a866e34 100644 --- a/Sources/Utils.m +++ b/Sources/Utils.m @@ -43,7 +43,7 @@ return nil; } -void showErrorAlert(NSString *title, NSString *message) { +void showErrorAlert(NSString *title, NSString *message, void (^completion)(void)) { dispatch_async(dispatch_get_main_queue(), ^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:title @@ -52,7 +52,11 @@ void showErrorAlert(NSString *title, NSString *message) { UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault - handler:nil]; + handler:^(UIAlertAction *action) { + if (completion) { + completion(); + } + }]; [alert addAction:okAction];