Last active
June 7, 2022 12:19
-
-
Save shahsurajk/8a6e4b050d792d38c4056b808b3cb3df to your computer and use it in GitHub Desktop.
OTP Service
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
class OtpService { | |
// .. other methods for cache store etc. | |
fun generateAndSendOtp(number: String) { | |
val otp = generateOtp(number) | |
// save OTP to cache | |
// send the OTP to number | |
sendOtp(number, otp) | |
} | |
private fun generateOtp(number: String): String { | |
// .. | |
} | |
private fun sendOtp(number: String, otp: String) { | |
// .. sending the SMS/EMail | |
} | |
fun verifyOtp(number: String, otp: String): Boolean { | |
// verification with the cache | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment