diff --git a/AmiKoOSX/MLADSwissOAuthWindowController.m b/AmiKoOSX/MLADSwissOAuthWindowController.m index 02a9b91..ff372f2 100644 --- a/AmiKoOSX/MLADSwissOAuthWindowController.m +++ b/AmiKoOSX/MLADSwissOAuthWindowController.m @@ -24,7 +24,7 @@ - (void)receivedTokens:(id)tokens { [[MLPersistenceManager shared] setHINADSwissTokens:tokens]; typeof(self) __weak _self = self; dispatch_async(dispatch_get_main_queue(), ^{ - [self.window.sheetParent endSheet:self.window + [_self.window.sheetParent endSheet:_self.window returnCode:NSModalResponseOK]; }); } diff --git a/HINClient/MLHINClient.m b/HINClient/MLHINClient.m index 333be35..a714211 100644 --- a/HINClient/MLHINClient.m +++ b/HINClient/MLHINClient.m @@ -39,6 +39,14 @@ - (NSURL *)authURLForADSwiss { ]; } +- (NSString*)HINDomainForADSwiss { +#ifdef DEBUG + return @"oauth2.ci-prep.adswiss.hin.ch"; +#else + return @"oauth2.ci.adswiss.hin.ch"; +#endif +} + - (void)fetchAccessTokenWithAuthCode:(NSString *)authCode completion:(void (^_Nonnull)(NSError * _Nullable error, MLHINTokens * _Nullable tokens))callback { @@ -171,7 +179,7 @@ - (void)fetchADSwissSAMLWithToken:(MLHINTokens *)token completion:(void (^_Nonnu callback(error, nil); return; } - NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://oauth2.ci-prep.adswiss.hin.ch/authService/EPDAuth?targetUrl=http%3A%2F%2Flocalhost%3A8080%2Fcallback&style=redirect"]]; + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://%@/authService/EPDAuth?targetUrl=http://localhost:8080/callback&style=redirect", [self HINDomainForADSwiss]]]]; [request setAllHTTPHeaderFields:@{ @"Accept": @"application/json", @"Authorization": [NSString stringWithFormat:@"Bearer %@", token.accessToken], @@ -208,7 +216,7 @@ - (void)fetchADSwissAuthHandleWithToken:(MLHINTokens *)token callback(error, nil); return; } - NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://oauth2.ci-prep.adswiss.hin.ch/authService/EPDAuth/auth_handle"]]; + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://%@/authService/EPDAuth/auth_handle", [self HINDomainForADSwiss]]]]; [request setAllHTTPHeaderFields:@{ @"Accept": @"application/json", @"Content-Type": @"application/json",