 
         if let username = self.username.text, let password = self.password.text
             where username.characters.count > 0 && password.characters.count > 0 {
-
-                let parameters: Dictionary<String, AnyObject> = [
-                    "username": username,
-                    "password": password
-                ]
-
-                SVProgressHUD.showWithMaskType(SVProgressHUDMaskType.Black)
-                LoginService.request(.POST, "", parameters: parameters).validate()
-                    .responseJSON() { response in
-                        SVProgressHUD.dismiss()
-
-
-                        if response.result.isSuccess {
-                            switch response.response!.statusCode {
-                            case 201:
-                                self.login(response.result.value!)
-
-                            default:
-                                print("perform_login action: unknown status code")
+                
+                if LoginKitConfig.authType == AuthType.JWT {
+                    let parameters: Dictionary<String, AnyObject> = [
+                        "username": username,
+                        "password": password
+                    ]
+                    
+                    SVProgressHUD.showWithMaskType(SVProgressHUDMaskType.Black)
+                    LoginService.request(.POST, "", parameters: parameters).validate()
+                        .responseJSON() { response in
+                            SVProgressHUD.dismiss()
+                            
+                            
+                            if response.result.isSuccess {
+                                switch response.response!.statusCode {
+                                case 201:
+                                    self.save_token(response.result.value!)
+                                    
+                                default:
+                                    print("perform_login action: unknown status code")
+                                }
                             }
-                        }
+                    }
+
                 }
-
+                
+                if LoginKitConfig.authType == AuthType.Basic {
+                    
+                    SVProgressHUD.showWithMaskType(SVProgressHUDMaskType.Black)
+                    LoginService.request(.GET, "", parameters: nil).validate()
+                        .authenticate(user: username, password: password)
+                        .responseJSON() { response in
+                            SVProgressHUD.dismiss()
+                            
+                            if response.result.isSuccess {
+                                switch response.response!.statusCode {
+                                case 201:
+                                    self.open_destination()
+                                    
+                                default:
+                                    print("perform_login action: unknown status code")
+                                }
+                            }
+                    }
+                }
+
+                
         } else {
             let alert = UIAlertController(title: nil, message: "Please enter your username and password.", preferredStyle: .Alert)
             alert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))

        }
    }

    func login(result: AnyObject) {
        #if !RELEASE
            NSLog("GET Result: \(result)")
        #endif

        var json = JSON(result)


        user.authToken = json["token"].stringValue

        LoginService.user = user

        open_destination()
    }
