Browse Source

Protocol login web

Marino Faggiana 8 years ago
parent
commit
3c9e64a574

+ 1 - 0
iOSClient/Brand/CCNextcloudConstant.h

@@ -28,6 +28,7 @@
 #define k_loginBaseUrl                  @"https://cloud.twsweb.it"
 #define k_pushNotificationServer        @"https://push-notifications.nextcloud.com"
 #define k_loginButtonLabelLink          @"https://nextcloud.com/providers"
+#define k_webLoginAutenticationProtocol @""
 
 // Capabilities Group
 #define k_capabilitiesGroups            @"group.it.twsweb.Crypto-Cloud"

+ 0 - 23
iOSClient/Login/CCLogin.m

@@ -250,29 +250,6 @@
         
             // Add default account
             [CCCoreData addAccount:account url:self.baseUrl.text user:self.user.text password:self.password.text];
-            
-// ---------------------------------------
-//  *** DEFAULT OPTION ***
-// ---------------------------------------
-            
-#ifdef OPTION_AUTOMATIC_UPLOAD_ENABLE
-            
-            [CCCoreData setCameraUpload:YES activeAccount:account];
-            
-            // Default parameter
-            [CCCoreData setCameraUploadFolderName:nil activeAccount:account];
-            [CCCoreData setCameraUploadFolderPath:nil activeUrl:self.baseUrl.text activeAccount:account];
-            
-            [CCCoreData setCameraUploadPhoto:YES activeAccount:account];
-            [CCCoreData setCameraUploadDatePhoto:[NSDate date]];
-
-            [CCCoreData setCameraUploadVideo:YES activeAccount:account];
-            [CCCoreData setCameraUploadWWanVideo:YES activeAccount:account];
-            [CCCoreData setCameraUploadDateVideo:[NSDate date]];
-            
-            [CCCoreData setCameraUploadCreateSubfolderActiveAccount:YES activeAccount:account];
-#endif
-            
         }
         
         TableAccount *tableAccount = [CCCoreData setActiveAccount:account];

+ 34 - 2
iOSClient/Login/CCLoginWeb.swift

@@ -8,8 +8,17 @@
 
 import UIKit
 
+public protocol CCLoginDelegate: class {
+    func loginSuccess(loginType: Int)
+}
+
 class CCLoginWeb: UIViewController {
 
+    var viewController : UIViewController?
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    
+    public weak var delegate: CCLoginDelegate?
+    
     override func viewDidLoad() {
         super.viewDidLoad()
     }
@@ -19,7 +28,9 @@ class CCLoginWeb: UIViewController {
     }
     
     func presentModalWithDefaultTheme(_ vc: UIViewController) {
-                
+        
+        self.viewController = vc
+        
         let webVC = SwiftModalWebVC(urlString: k_loginBaseUrl, theme: .loginWeb)
         webVC.delegateWeb = self
         vc.present(webVC, animated: true, completion: nil)
@@ -33,7 +44,28 @@ extension CCLoginWeb: SwiftModalWebVCDelegate {
     }
     
     func didReceiveServerRedirectForProvisionalNavigation(url: URL) {
-        print(url)
+        
+        let urlString: String = url.absoluteString
+        
+        if (urlString.contains(k_webLoginAutenticationProtocol) == true) {
+            
+            let keyValue = url.path.components(separatedBy: "&")
+            if (keyValue.count == 3) {
+                
+                let serverUrl : String = String(keyValue[0].replacingOccurrences(of: "/server:", with: "").characters.dropLast())
+                let username : String = keyValue[1].replacingOccurrences(of: "user:", with: "")
+                let password : String = keyValue[2].replacingOccurrences(of: "password:", with: "")
+                
+                let account : String = "\(username) \(serverUrl)"
+                
+                CCCoreData.addAccount(account, url: serverUrl, user: username, password: password)
+                appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activePassword: password)
+                
+                self.delegate?.loginSuccess(loginType: 0)
+                
+                self.viewController?.dismiss(animated: true, completion: nil)
+            }
+        }
     }
 
     func didFinishLoading(success: Bool, url: URL) {

+ 23 - 0
iOSClient/Main/CCSplit.m

@@ -142,6 +142,28 @@
 
 - (void)loginSuccess:(NSInteger)loginType
 {
+    // ---------------------------------------
+    //  *** DEFAULT OPTION ***
+    // ---------------------------------------
+    
+#ifdef OPTION_AUTOMATIC_UPLOAD_ENABLE
+    
+    [CCCoreData setCameraUpload:YES activeAccount:app.activeAccount];
+    
+    // Default parameter
+    [CCCoreData setCameraUploadFolderName:nil activeAccount:app.activeAccount];
+    [CCCoreData setCameraUploadFolderPath:nil activeUrl:app.activeUrl activeAccount:app.activeAccount];
+    
+    [CCCoreData setCameraUploadPhoto:YES activeAccount:app.activeAccount];
+    [CCCoreData setCameraUploadDatePhoto:[NSDate date]];
+    
+    [CCCoreData setCameraUploadVideo:YES activeAccount:app.activeAccount];
+    [CCCoreData setCameraUploadWWanVideo:YES activeAccount:app.activeAccount];
+    [CCCoreData setCameraUploadDateVideo:[NSDate date]];
+    
+    [CCCoreData setCameraUploadCreateSubfolderActiveAccount:YES activeAccount:app.activeAccount];
+#endif
+
     [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
 }
 
@@ -152,6 +174,7 @@
 #ifdef LOGIN_WEB
         
         _loginWeb = [CCLoginWeb new];
+        _loginVC.delegate = self;
         [_loginWeb presentModalWithDefaultTheme:self];
         
 #else