Hey devs π
Let's make OTP login system in just 5 lines of codes (and it's possible broπ±π). There's legendary codes:
const AuthVerify = require('auth-verify');
const auth = new AuthVerify({storeTokens: 'memory', otpExpiry: '5m'}); // we save our otp in memory and otp expires after 5 minutes
auth.otp.setSender({via: 'telegram', token: 'BOT_TOKEN_HERE'}); // preparing otp sender bot
auth.otp.generate(5).set('USER_PHONE'); // we save our otp code with the key 'USER_PHONE' in memory and length of otp code is 5
auth.otp.message({to: 'USER_PHONE'}); // sending otp to user. And that's done
And let's check the result:
The logic is when user commands /start to bot .Bot requests from user his/her phone number and checks whether OTP saved for him/her in memory

Top comments (0)