Files
hotpocket/services/apple/macOS (App)/AuthorizationViewController.m
Tomek Wójcik 55126f4af6 BTHLABS-66: Prepping for public release: Take five
AKA "Using Apple reviewers as QA for your project". Thanks, y'all! :)
2025-11-27 17:51:19 +01:00

55 lines
1.4 KiB
Objective-C

//
// AuthorizationViewController.m
// HotPocket (macOS)
//
// Created by Tomek Wójcik on 20/09/2025.
//
#import "AuthorizationViewController.h"
#import "AppDelegate.h"
#import "AuthorizationProgressViewController.h"
#import "HPAuthFlow.h"
#import "ReplaceAnimator.h"
@interface AuthorizationViewController (AuthorizationViewControllerPrivate)
#pragma mark - Private interface
@end
@implementation AuthorizationViewController
#pragma mark - View lifecycle
-(void)viewDidLoad {
[super viewDidLoad];
self.baseURL = nil;
self.authorizationSessionToken = nil;
}
#pragma mark - Actions
-(IBAction)doStartAuthorizationFlow:(id)sender {
AppDelegate *appDelegate = [[NSApplication sharedApplication] delegate];
appDelegate.authFlow.baseURL = [NSURL URLWithString:self.baseURL];
NSURL *authURL = [appDelegate.authFlow start];
if (authURL == nil) {
NSBeep();
return;
}
AuthorizationProgressViewController *authProgressViewController = [self.storyboard instantiateControllerWithIdentifier:@"AuthorizationProgressViewController"];
authProgressViewController.authorizationURL = authURL;
[self presentViewController:authProgressViewController animator:[[ReplaceAnimator alloc] init]];
}
# pragma mark - ASWebAuthenticationPresentationContextProviding implementation
-(ASPresentationAnchor)presentationAnchorForWebAuthenticationSession:(ASWebAuthenticationSession *)session {
return self.view.window;
}
@end