50 lines
1.2 KiB
Objective-C
50 lines
1.2 KiB
Objective-C
//
|
|
// AuthorizationViewController.m
|
|
// HotPocket (macOS)
|
|
//
|
|
// Created by Tomek Wójcik on 20/09/2025.
|
|
//
|
|
|
|
#import "AuthorizationViewController.h"
|
|
|
|
#import "AppDelegate.h"
|
|
#import "HPAuthFlow.h"
|
|
#import "AuthorizationProgressViewController.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 *appDeleate = [[NSApplication sharedApplication] delegate];
|
|
appDeleate.authFlow.baseURL = [NSURL URLWithString:self.baseURL];
|
|
|
|
NSURL *authURL = [appDeleate.authFlow start];
|
|
if (authURL == nil) {
|
|
NSBeep();
|
|
return;
|
|
}
|
|
|
|
AuthorizationProgressViewController *authProgressViewController = [self.storyboard instantiateControllerWithIdentifier:@"AuthorizationProgressViewController"];
|
|
[self presentViewController:authProgressViewController animator:[[ReplaceAnimator alloc] init]];
|
|
|
|
[[NSWorkspace sharedWorkspace] openURL:authURL];
|
|
}
|
|
|
|
@end
|