Login function created with addition of MongoDB.