From 99a433a0fce443c92ef6dae35a18583cb6ec4d0f Mon Sep 17 00:00:00 2001 From: Amir Abbas Mousavian Date: Sun, 26 Mar 2017 15:54:55 +0430 Subject: [PATCH] Credential is open to set anytime --- Sources/DropboxFileProvider.swift | 2 +- Sources/FileProvider.swift | 4 ++-- Sources/LocalFileProvider.swift | 2 +- Sources/OneDriveFileProvide.swift | 2 +- Sources/SMBFileProvider.swift | 2 +- Sources/WebDAVFileProvider.swift | 6 +++++- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Sources/DropboxFileProvider.swift b/Sources/DropboxFileProvider.swift index c9b7718..5c65bbb 100644 --- a/Sources/DropboxFileProvider.swift +++ b/Sources/DropboxFileProvider.swift @@ -34,7 +34,7 @@ open class DropboxFileProvider: FileProviderBasicRemote { } open weak var delegate: FileProviderDelegate? - open let credential: URLCredential? + open var credential: URLCredential? open private(set) var cache: URLCache? public var useCache: Bool public var validatingCache: Bool diff --git a/Sources/FileProvider.swift b/Sources/FileProvider.swift index 2212503..5d045c4 100644 --- a/Sources/FileProvider.swift +++ b/Sources/FileProvider.swift @@ -51,13 +51,13 @@ public protocol FileProviderBasic: class, NSCoding, NSSecureCoding { **Example initialization:** ```` - let credential = URLCredential(user: "user", password: "password", persistence: .forSeession) + provider.credential = URLCredential(user: "user", password: "password", persistence: .forSeession) ```` - Note: In OAuth based providers like `DropboxFileProvider` and `OneDriveFileProvider`, password is Token. use [OAuthSwift](https://github.com/OAuthSwift/OAuthSwift) library to fetch clientId and Token of user. */ - var credential: URLCredential? { get } + var credential: URLCredential? { get set } /** Returns an Array of `FileObject`s identifying the the directory entries via asynchronous completion handler. diff --git a/Sources/LocalFileProvider.swift b/Sources/LocalFileProvider.swift index 34f2662..a9a0277 100644 --- a/Sources/LocalFileProvider.swift +++ b/Sources/LocalFileProvider.swift @@ -21,7 +21,7 @@ open class LocalFileProvider: FileProvider, FileProviderMonitor, FileProvideUndo open var dispatch_queue: DispatchQueue open var operation_queue: OperationQueue open weak var delegate: FileProviderDelegate? - open internal(set) var credential: URLCredential? + open var credential: URLCredential? /// Underlying `FileManager` object for listing and metadata fetching. open private(set) var fileManager = FileManager() diff --git a/Sources/OneDriveFileProvide.swift b/Sources/OneDriveFileProvide.swift index e57895a..3a56588 100644 --- a/Sources/OneDriveFileProvide.swift +++ b/Sources/OneDriveFileProvide.swift @@ -33,7 +33,7 @@ open class OneDriveFileProvider: FileProviderBasicRemote { } open weak var delegate: FileProviderDelegate? - open let credential: URLCredential? + open var credential: URLCredential? open private(set) var cache: URLCache? public var useCache: Bool public var validatingCache: Bool diff --git a/Sources/SMBFileProvider.swift b/Sources/SMBFileProvider.swift index f7ac059..ebdefe4 100644 --- a/Sources/SMBFileProvider.swift +++ b/Sources/SMBFileProvider.swift @@ -15,7 +15,7 @@ class SMBFileProvider: FileProvider, FileProviderMonitor { open var dispatch_queue: DispatchQueue open var operation_queue: OperationQueue open weak var delegate: FileProviderDelegate? - open let credential: URLCredential? + open var credential: URLCredential? public typealias FileObjectClass = FileObject diff --git a/Sources/WebDAVFileProvider.swift b/Sources/WebDAVFileProvider.swift index 2ff86b3..dac91f8 100644 --- a/Sources/WebDAVFileProvider.swift +++ b/Sources/WebDAVFileProvider.swift @@ -32,7 +32,11 @@ open class WebDAVFileProvider: FileProviderBasicRemote { } public weak var delegate: FileProviderDelegate? - open let credential: URLCredential? + open var credential: URLCredential? { + didSet { + sessionDelegate?.credential = credential + } + } open private(set) var cache: URLCache? public var useCache: Bool public var validatingCache: Bool