Advanced Node and Express - Implement the Serialization of a Passport User- OP_MVDM

Hello everyone,

I have recently posted on step 7 of the Section " Advanced Node and Express": How to Use Passport Strategies - and I was stuck due to some DB connection errors / wrong URI…

I have restarted the challenges on a new glitch project and have reached the " Implement the Serialization of a Passport User" step.
I m pretty solid on the code as I used my previous one (which reaches two steps further) but I am still a big newbie and can’t understand my database mistakes.

Here is the error as in the log:

.env: line 1: 7: command not found

12:48 PM

.env: line 2: XXX: No such file or directory

12:48 PM

Thu, 06 Feb 2020 11:48:15 GMT express-session deprecated req.secret; provide secret option at server.js:32:3

12:48 PM

Database error: MongoParseError: URI malformed, cannot be parsed

Here is my .env file (I adapted the password in the real code) :

SESSION_SECRET= “7”
DATABASE =mongodb+srv://OPMVDM:@cluster0-zlfwm.azure.mongodb.net/test?retryWrites=true&w=majority

The glitch project:

https://great-pig-l5h7zys35.glitch.me

Help!..

Thanks in advance,

OP-MVDM,

Chrome/Brave - Win 8

does adding quotes here help?

DATABASE ="mongodb+srv://OPMVDM:@cluster0-zlfwm.azure.mongodb.net/test?retryWrites=true&w=majority"

Nope…

This is what I wrote:

DATABASE =“mongodb+srv://OPMVDM:@cluster0-zlfwm.azure.mongodb.net/test?retryWrites=true&w=majority”

Logs:

.env: line 2: DATABASE: command not found

3:30 PM

Database error: MongoParseError: URI malformed, cannot be parsed

Anyone can help me here?

Thanks?

I can’t load your Glitch project for some reason. It’s stuck in loading, not sure why :thinking:

here is an example of my .env:

SESSION_SECRET='imaword'
DATABASE='mongodb://pjonp:Tfpasswordkt@cluster0-shard-03-10-tovxz.mongodb.net:28027,cluster0-shard-03-00-tovxz.mongodb.net:28027,cluster0-shard-00-02-tovxz.mongodb.net:28027/test?ssl=true&replicaSet=Cluster0-shard-3&authSource=admin&retryWrites=true&w=majority'

This is just an example; the ‘imaword’ is the same though and I replaced password. You’ll have to check your DATABASE URI again maybe? What I show is just an example, we would be on different clusters/shards.

… i still can’t load your Glitch, after about 10 minutes waiting. So maybe try to start a new boilerplate and copy/paste into it?

1 Like

Dear pjonp,

Sorry for the late answer - just got back at this project from scratch and eventhough I succesfully pass the test at the Implement the Serialization of a Passport User section , I am, still no able to get connected to my MongoDB Atlas.

I tried different things and managed to get my URI right by adding quotes and this to my mongo connector : {useUnifiedTopology: true}, {useNewUrlParser: true},

YET, it is not working still… So, here is the link to my glitch.

Thanks in advance for the help,

OP,