Skip to content

Commit

Permalink
Expose onForgotPassword [SDK-2632] (#673)
Browse files Browse the repository at this point in the history
* Expose onForgotPassword

* Add unit test for the public API method

* Fix test
  • Loading branch information
Widcket authored Jul 19, 2021
1 parent ce713f7 commit b29d5db
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Lock/Lock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,19 @@ public class Lock: NSObject {
return self
}

/**
Register a callback to be notified when a user requests a password reset.
The callback will yield the user identifier.
- parameter callback: called when a user requests a password reset.
- returns: Lock itself for chaining
*/
public func onForgotPassword(callback: @escaping (String) -> Void) -> Lock {
self.observerStore.onForgotPassword = callback
return self
}

/**
Presents Lock from the given controller
Expand Down Expand Up @@ -277,7 +290,7 @@ public class Lock: NSObject {
return self
}

/// Lock's Bundle. Useful for getting bundled resources like images.
/// Lock's Bundle. Useful for getting bundled resources like images.
public static var bundle: Bundle {
return bundleForLock()
}
Expand Down
8 changes: 8 additions & 0 deletions LockTests/LockSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ class LockSpec: QuickSpec {
expect(executed) == true
}

it("should register onForgotPassword callback") {
var email: String? = nil
let callback: (String) -> () = { email = $0 }
let _ = lock.onForgotPassword(callback: callback)
lock.observerStore.onForgotPassword("mail@mail.com")
expect(email) == "mail@mail.com"
}

it("should register onPasswordless callback") {
var email: String? = nil
let callback: (String) -> () = { email = $0 }
Expand Down

0 comments on commit b29d5db

Please sign in to comment.