From 77ae7656e6fb24f8277d7ced1c61a753b8689799 Mon Sep 17 00:00:00 2001 From: Pablo Carrascal Date: Fri, 1 Dec 2017 11:01:39 +0100 Subject: [PATCH] firts changes to avoid duplicated sessions --- .../Login/Login/WebLoginViewController.swift | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Owncloud iOs Client/Login/Login/WebLoginViewController.swift b/Owncloud iOs Client/Login/Login/WebLoginViewController.swift index c4b8d16f70..3d54274621 100644 --- a/Owncloud iOs Client/Login/Login/WebLoginViewController.swift +++ b/Owncloud iOs Client/Login/Login/WebLoginViewController.swift @@ -42,6 +42,12 @@ import Foundation } func closeLoginViewController() { +// UtilsFramework.deleteAllCookies() + let app: AppDelegate = (UIApplication.shared.delegate as! AppDelegate) + + if app.activeUser != nil { + UtilsCookies.deleteCurrentSystemCookieStorageAndRestoreTheCookiesOfActiveUser() + } self.performSegue(withIdentifier: K.unwindId.unwindToMainLoginView, sender: self) } @@ -51,11 +57,15 @@ import Foundation super.viewDidLoad() self.webViewLogin.delegate = self self.webViewLogin.backgroundColor = UIColor.ofWebViewBackground() - + let app: AppDelegate = (UIApplication.shared.delegate as! AppDelegate) // Do any additional setup after loading the view. - + + if let user = app.activeUser { + UtilsCookies.setOnDBStorageCookiesByUser(user) + } + //load login url in web view - let app: AppDelegate = (UIApplication.shared.delegate as! AppDelegate) + self.oAuth2Manager.trustedCertificatesStore = self.sslCertificateManager let urlToGetAuthCode = self.oAuth2Manager.getOAuth2URLToGetAuthCode(by: app.oauth2Configuration, withServerPath: serverPath) self.loadWebViewWith(url: urlToGetAuthCode!) @@ -76,7 +86,6 @@ import Foundation self.webViewLogin.loadRequest(request) } - // MARK: webView delegates func webViewDidStartLoad(_ webView: UIWebView) { @@ -114,6 +123,7 @@ import Foundation if urlToFollow.hasPrefix(k_oauth2_redirect_uri){ processFinalRedirect(urlToFollow); self.loadInterrupted = true; + return false; // will trigger webView(webView, didFailLoadWithError), with error due to cancellation } else if urlToFollow.hasPrefix(serverPath + k_url_path_list_of_files_in_web) {