Skip to content

Commit de45426

Browse files
committed
Bugfix in manual authentication
1 parent d282da8 commit de45426

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog Cobalt
22

3+
## v5.9.2 (19-06-2019)
4+
- Bugfix manual auth provider
5+
36
## v5.9.1 (19-06-2019)
47
- Provide a way to store the login state when logging in manually
58

@@ -65,4 +68,4 @@
6568
- Store `AccessToken` in individual keychains per host, this way you can use multiple `Cobalt` isntances for multiple API's.
6669

6770
## v5.0.0 (11-07-2018)
68-
- Initial public release
71+
- Initial public release

Cobalt.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Cobalt"
3-
s.version = "5.9.1"
3+
s.version = "5.9.2"
44
s.author = { "Bas van Kuijck" => "[email protected]" }
55
s.license = { :type => "MIT", :file => "LICENSE" }
66
s.homepage = "http://www.e-sites.nl"

Sources/Core/Authentication/AccessToken.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ public class AccessToken: Decodable, CustomStringConvertible {
7474
return accessToken
7575
}
7676

77-
init(grantType: OAuthenticationGrantType, accessToken: String, refreshToken: String, expireDate: Date, host: String? = nil) {
77+
init(grantType: OAuthenticationGrantType, accessToken: String, refreshToken: String, expireDate: Date, host: String) {
7878
self.grantType = grantType
7979
self.accessToken = accessToken
8080
self.refreshToken = refreshToken
8181
self.expireDate = expireDate
82-
self.host = host ?? ""
82+
self.host = host
83+
84+
_setKeychain()
8385
}
8486

8587
init(host: String) {

Sources/Core/Authentication/AuthenticationProvider.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,8 @@ class AuthenticationProvider {
191191
accessToken: String,
192192
refreshToken: String,
193193
expireDate: Date,
194-
host: String? = nil) {
195-
let oauthHost = (host ?? client.config.host) ?? ""
196-
let accessTokenObject = AccessToken(grantType: grantType, accessToken: accessToken, refreshToken: refreshToken, expireDate: expireDate, host: oauthHost)
194+
host: String) {
195+
let accessTokenObject = AccessToken(grantType: grantType, accessToken: accessToken, refreshToken: refreshToken, expireDate: expireDate, host: host)
197196
accessTokenObject.store()
198197

199198
client.logger?.debug("Store access-token: \(optionalDescription(accessToken))")

Sources/Core/Base/Client.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,11 @@ open class Client: ReactiveCompatible {
233233
public func loggedIn(grantType: OAuthenticationGrantType,
234234
accessToken: String,
235235
refreshToken: String,
236-
expireDate: Date,
237-
host: String? = nil) {
236+
expireDate: Date) {
237+
guard let host = (host ?? config.host) else {
238+
fatalError("No host given, nor a valid host set in the Cobalt.Config")
239+
}
240+
238241
authProvider.handleManualOAuthRequest(grantType: grantType, accessToken: accessToken, refreshToken: refreshToken, expireDate: expireDate, host: host)
239242
}
240243

0 commit comments

Comments
 (0)