Closed TheRyan1 closed 2 years ago
how this close, i have same question
what a answer for this question, i need pls
how this close, i have same question
User's logged in with an email and password. Then connected their account using their phone number. Once authenticated, I stored the session generated by auth.signIn method into the db. So each time they made a call to the mtproto methods, it would use the stored session.
try {
const { session } = await User.findById(req.id);
const parsedSession = JSON.parse(session);
if (Object.keys(parsedSession).length > 3) {
let tempStorage = new Storage();
for (let [key, value] of Object.entries(parsedSession)) {
tempStorage.set(key, value);
}
const _MTproto = new MTprotoAPI(tempStorage);
const user = await _MTproto.getUser();
if (user.user) {
res.send({ user: user.user, step: "dashboard" });
} else {
res.send("An error occured");
}
} else {
res.send({ message: "Sign in required", step: "enterPhone" });
}
} catch (err) {
console.log(err);
}
tq for answer
When init MTproto in the backend, the session information used is for a single user. Is there a way that multiple users would be able to use a single instance? Or would each user need a new instance with their own session data?
What I want to do: Login from the front end and call the methods from the backend
Context: