Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make OTP delivery independent of 2FA gem (#452)
**Why**: We should not have to modify the `send_two_factor_authentication_code` method in the `two_factor_authentication` gem in order to accommodate multiple delivery mechanisms. This violates the "O" in the SOLID object-oriented design principles. The "O" stands for Open for extension, Closed for modification. **How**: We can work around the gem's undesirable design choices by making a few sensible changes: - Make the `send_two_factor_authentication_code` method a no-op method, i.e. it doesn't do anything. This means that even though the gem calls this method right after Warden signs the user in, nothing will happen, which is what we want. - Instead of relying on the `send_two_factor_authentication_code` method and the `UserOtpSender` class to invoke the proper background job, we do this work in the controller, and use the delivery method chosen by the user to determine which job to invoke. This allows us to continue our work without having to fork the gem or wait for our PRs to be approved and merged. We can work on our code the way we want and propose changes to the gem in parallel, without one depending on the other. Note that these are the smallest changes I could come up with to remove the dependency on Amos's fork, without changing behavior. Due to preexisting duplication, new duplication was introduced, but it will be cleaned up in subsequent PRs, which are part of a larger refactor I am working on.
- Loading branch information
Showing
11 changed files
with
36 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.