Skip to content

Commit b29d5db

Browse files
authored
Expose onForgotPassword [SDK-2632] (#673)
* Expose onForgotPassword * Add unit test for the public API method * Fix test
1 parent ce713f7 commit b29d5db

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Lock/Lock.swift

+14-1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,19 @@ public class Lock: NSObject {
250250
return self
251251
}
252252

253+
/**
254+
Register a callback to be notified when a user requests a password reset.
255+
The callback will yield the user identifier.
256+
257+
- parameter callback: called when a user requests a password reset.
258+
259+
- returns: Lock itself for chaining
260+
*/
261+
public func onForgotPassword(callback: @escaping (String) -> Void) -> Lock {
262+
self.observerStore.onForgotPassword = callback
263+
return self
264+
}
265+
253266
/**
254267
Presents Lock from the given controller
255268

@@ -277,7 +290,7 @@ public class Lock: NSObject {
277290
return self
278291
}
279292

280-
/// Lock's Bundle. Useful for getting bundled resources like images.
293+
/// Lock's Bundle. Useful for getting bundled resources like images.
281294
public static var bundle: Bundle {
282295
return bundleForLock()
283296
}

LockTests/LockSpec.swift

+8
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,14 @@ class LockSpec: QuickSpec {
176176
expect(executed) == true
177177
}
178178

179+
it("should register onForgotPassword callback") {
180+
var email: String? = nil
181+
let callback: (String) -> () = { email = $0 }
182+
let _ = lock.onForgotPassword(callback: callback)
183+
lock.observerStore.onForgotPassword("[email protected]")
184+
expect(email) == "[email protected]"
185+
}
186+
179187
it("should register onPasswordless callback") {
180188
var email: String? = nil
181189
let callback: (String) -> () = { email = $0 }

0 commit comments

Comments
 (0)