I am fetching user likes on a particular photo and saving usernames on DB, works fine.
But I want to know if a user changed there username, how I can track this user is one who liked my photo, because username saved on DB will be not same after user changed username.
How I can track this?. I am working on project so its a client requirement.
Save user_id instead of usernames, user_id will not change when username is changed.
Related
i am just a beginning, with node/express and i kinda have a problem.
i have built a todo application using, node js express and mongo db which actually has an login/register form...i.e, u get to register and login (/register) and(/login) before you can get access to the todo application(/todoapp).
My problem is, if user A logs in with his email and password, inputs some todos and logout, later on user B also get to login with his own different email and password, he gets to see the todos of user A.
but then i want it to be different, user A should be able to see just his own todo, user B should also be able to see just his own todos, please how do i do that?
Please my algorithm is below
-user registers (/register)
-user gets redirected to (/login)
***successfully logins and gets to (/todos)
this works perfectly and sends all logged in users to the same (/todo)
Generally you need to store the user _id in a session or a cookie (in the client side) when the user login successfully, then when the user make get/post request first you check if the _id in his seesion/cookie match to the _id in the db and sending back to the user only the items with his _id (items that belong to the user).
you can register a session when the user logs in but keep in mind you must to protect against csrf.
You can also use JWT for this.
I will suggest you to find good tutorial for JWT or authorisation with session and csrf protect.
Its a big subject and its better to watch a good video or read a good article than copy paste code from here.
I know that the Uid of authenticated user on firebase is unique.
But, I can not be sure that uid of the deleted user will not be re used by the new user.
I could not find an explanation for this.
I need experience or information related to this.
I think the uid will always be unique. It is actually based on the timestamp and other factors so it will be unique.
Info on how firebase generates it :
How does Firebase generate the Uid?
And about their uniqueness:
https://towardsdatascience.com/are-uuids-really-unique-57eb80fc2a87
If you still want to set your custom uid for a user for any analytics purpose :
https://firebase.google.com/docs/analytics/userid
I want to build a small app which connects to a DB and from where you can manipulate that DB.
I am using MongoDB with Node, with passport, passport-local, mongoose. In order to access this app, you need to login but I don't want a register page. I want to add users myself in mongo. (because registering isn't open to anyone and I want only like 4-5 users)
I will make a db in Mongo with 2 collections: 1 which contains the users and 1 which will contain the data.
My problem is how to build the users collection/table without the register page? I don't know how to hash the password and do all the things without the register page, just by myself. I think I can insert each user with a name and a password, and if the password entered on the app equals with the one in the database it will log the person in.
But that will defeat the purpose of passport, password hashing and ect.
So my question is: how to create preset users without a register page in my case? What would be the best way?
I am using Python-Telegram-Bot API to create a bot. I get people's userID and username when they start the bot.
The userID doesn't change ever but the username can be changed by the user any time.
So I have usernames and UserIDs, and I receive another username - I wish to figure out whether that username is of someone already in the existing list or not.
Basically need to find out username from userID or if there's any other way I'm open to it.
thats why you always process messages using the users' IDs
but to answer your question, you can either get the user's username directly using the user object, for example update.message.from_user.username or update.effective_user.username
or use bot.getchat(chat_id) to get an user object of a certain chat (which could be an user's private chat
I have a route on my site that displays a badge for a particular user. It works because in the query string that user's id is provided. The database is checked to see if that user has that certification, and then the page is displayed with that user's public info. Currently, the text of the email is that users id. I'd like to user something a little more anonymous. A short unique id.
But, if I do md5 hash or something, then I can't go back to the email so that I can look them up in the database. What is a way I can go back and forth from unique id to email back to unique id? I'm building with node.js, so perhaps something int he crypto library?