Skip to content

Commit 793a9b0

Browse files
committed
Re-add dismissLoginController()
1 parent d14beed commit 793a9b0

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

Sources/Flows/OAuth2PasswordGrant.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,15 @@ open class OAuth2PasswordGrant: OAuth2 {
8888
super.init(settings: settings)
8989
}
9090

91+
92+
// MARK: - Auth Flow
93+
9194
/**
9295
Performs the accessTokenRequest if credentials are already provided, or ask for them with a native view controller.
9396

97+
If you choose to **not** automatically dismiss the login controller, you can do so on your own by calling
98+
`dismissLoginController(animated:)`.
99+
94100
- parameter params: Optional key/value pairs to pass during authorization
95101
*/
96102
override open func doAuthorize(params: OAuth2StringDict? = nil) throws {
@@ -125,8 +131,7 @@ open class OAuth2PasswordGrant: OAuth2 {
125131
self.customAuthParams = nil
126132

127133
if self.authConfig.authorizeEmbeddedAutoDismiss, (!wasFailure || error! == OAuth2Error.requestCancelled) {
128-
self.logger?.debug("OAuth2", msg: "Dismissing the login controller")
129-
self.customAuthorizer.dismissLoginController(animated: true)
134+
self.dismissLoginController(animated: true)
130135
}
131136
}
132137

@@ -168,6 +173,22 @@ open class OAuth2PasswordGrant: OAuth2 {
168173
}
169174
}
170175

176+
/**
177+
Dismiss the login controller, if any.
178+
179+
- parameter animated: Whether dismissal should be animated
180+
*/
181+
open func dismissLoginController(animated: Bool = true) {
182+
logger?.debug("OAuth2", msg: "Dismissing the login controller")
183+
customAuthorizer.dismissLoginController(animated: animated)
184+
if isAuthorizing {
185+
didFail(with: nil)
186+
}
187+
}
188+
189+
190+
// MARK: - Access Token Request
191+
171192
/**
172193
Creates a POST request with x-www-form-urlencoded body created from the supplied URL's query part.
173194

0 commit comments

Comments
 (0)