forked from organicmaps/organicmaps
[iOS] send access token only to catalog
This commit is contained in:
parent
b21bf4e8c0
commit
ee6d75b25c
3 changed files with 18 additions and 4 deletions
|
@ -113,6 +113,10 @@ final class CatalogWebViewController: WebViewController {
|
|||
handlePendingTransactions { decisionHandler($0) }
|
||||
}
|
||||
|
||||
override func shouldAddAccessToken() -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
override func webView(_ webView: WKWebView,
|
||||
decidePolicyFor navigationAction: WKNavigationAction,
|
||||
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||
|
|
|
@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
onSuccessAuth:(MWMStringBlock _Nullable)success
|
||||
onFailure:(MWMVoidBlock _Nullable)failure;
|
||||
- (void)willLoadUrl:(MWMBoolBlock)decisionHandler;
|
||||
- (BOOL)shouldAddAccessToken;
|
||||
- (void)forward;
|
||||
- (void)back;
|
||||
|
||||
|
|
|
@ -100,19 +100,28 @@
|
|||
{
|
||||
auto request = [NSMutableURLRequest requestWithURL:self.m_url];
|
||||
[request setValue:@(GetPlatform().GetAppUserAgent().Get().c_str()) forHTTPHeaderField:@"User-Agent"];
|
||||
auto authHeader = [NSString stringWithFormat:@"Bearer %@",
|
||||
@(GetFramework().GetUser().GetAccessToken().c_str())];
|
||||
[request setValue:authHeader forHTTPHeaderField:@"Authorization"];
|
||||
if (self.shouldAddAccessToken)
|
||||
{
|
||||
auto authHeader = [NSString stringWithFormat:@"Bearer %@",
|
||||
@(GetFramework().GetUser().GetAccessToken().c_str())];
|
||||
[request setValue:authHeader forHTTPHeaderField:@"Authorization"];
|
||||
}
|
||||
[self.webView loadRequest:request];
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)willLoadUrl:(MWMBoolBlock)decisionHandler {
|
||||
- (void)willLoadUrl:(MWMBoolBlock)decisionHandler
|
||||
{
|
||||
decisionHandler(YES);
|
||||
}
|
||||
|
||||
- (BOOL)shouldAddAccessToken
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewDidDisappear:animated];
|
||||
|
|
Loading…
Add table
Reference in a new issue