Am i doing right thing sir?
i have to query single email for user login so i develop this method
but this method won’t returning any error but can listing emails and it’s related details
can you help me to figure it out?
func Find_User(user *model.User) (*mongo.SingleResult, error) {
//Create a handle to the respective collection in the database.
//finding user data using email and password
query := bson.M{"email": user.Email}
collection := clientInstance.Database(AUTH_DB).Collection(USER_COLLECTION)
return collection.FindOne(context.TODO(), query), clientInstanceError
}
if you can i need another help sir how can i sit password and email authentication and return useful reply using this same code , if i use json response it shows some error . if you please help me because i can’t able to declare them straight away there
That really depends on you authentication implementation. You could compare the password you have for the user against the one is trying to use for log in and respond accordingly, but I wouldn’t do it at the storage level.