-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(condo): DOMA-11012 telegram auth #5783
base: main
Are you sure you want to change the base?
Conversation
22deb7c
to
3b31396
Compare
|
||
init () { | ||
if (this.#bot) { | ||
this.#bot.onText(/\/start (.+)/, this.#handleStart.bind(this)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth processing a simple /start
command?
const startData = await redisClient.get(`${TELEGRAM_AUTH_REDIS_START}${startKey}`) | ||
await redisClient.del(`${TELEGRAM_AUTH_REDIS_START}${startKey}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that forming a query in Redis based on user input without additional checks is not the best idea
|
||
if (!chatId || !contact) return | ||
|
||
const { phone_number: phoneNumber, first_name: firstName, user_id: userId } = contact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about lastname?
const redisClient = getRedisClient() | ||
|
||
class TelegramAuthRoutes { | ||
#telegramAuthBot = new TelegramAuthBotController() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you going to run the bot in every pod for condo-app
? Will this work well?
I thought it was supposed to be a separate pod for a bot
|
||
|
||
function getUserType (req) { | ||
let userType = RESIDENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why resident by default?
return res.status(400).json({ status: 'error', message: 'Missing uniqueKey' }) | ||
} | ||
|
||
const token = await redisClient.get(`${TELEGRAM_AUTH_REDIS_TOKEN}${uniqueKey}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is auth status, not token
return res.status(400).json({ status: TELEGRAM_AUTH_STATUS_ERROR, message: 'uniqueKey is expired' }) | ||
} | ||
|
||
if (token === TELEGRAM_AUTH_STATUS_PENDING) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you comparing the token with auth status?
const startLink = `${TELEGRAM_AUTH_BOT_URL}?start=${startKey}` | ||
|
||
await Promise.all([ | ||
redisClient.set(`${TELEGRAM_AUTH_REDIS_START}${startKey}`, JSON.stringify({ uniqueKey, userType }), 'EX', 300), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make a small utility for generating a key, so as not to generate it manually each time?
} = require('@condo/domains/user/utils/serverSchema') | ||
|
||
const dv = 1 | ||
const sender = { dv, fingerprint: 'user-external-identity-router' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's worth adding information to the fingerprint that this is an integration with Telegram?
if (existed) { | ||
return await linkUser(context, existed, userInfo) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set isPhoneVerified: true
for user?
|
No description provided.