GithubHelp home page GithubHelp logo

week-6-bhkm-'s Issues

Great use of no-js!!

Screenshot 2019-08-09 at 09 22 46

Had never heard of this before I checked out your code but had a quick google and think it's great that you're considering the no javascript user (although who would ever choose to disable js, right?!)

Nicely broken down

Super compartimentalised and makes the code nice to read and understand ๐Ÿ‘

Web view

Screenshot 2019-08-09 at 09 43 47

Not going to be harsh on the lack of css etc because it's not the point of this week, we don't have much (at least we didn't yesterday when I left) and it takes like, 15 mins to put together something. I love that the fields are required and won't let me submit a blank field. IF you have time, would be nice to get the dropdown to appear below the input field, and to have a 'please select here' in the input field, too. Otherwise, hope you have time to sprinkle some gorgeous CSS onto it!!

put .env in your gitignore!

It's generally not a good idea to push your .env file to github - this is where you tend to store secret stuff like api keys and (ahem) database usernames and passwords. Usually the .env never gets pushed to master, and you share the variables privately with the rest of your team

Data stream

If you have chance may be worth abstracting out your data streamer function as you use it a few times

Congrats

Great improvements on last week and feels like a proper app, lovely stuff

great

might be worth putting instructions at the top of the readme

I like the test database instructions (although it might be worth mentioning you'll need the test url from the .env file), but the git clone, npm install, npm start/test instructions are important too. As a code reviewer the first thing I want to do is get the code cloned and running! Generally a good idea to put these instructions near the top of your readme

Consistent use of ES6

Have had a quick scan through your repo and your use of ES6 is consistent and correct (from what I can gather). Great job! ๐Ÿ’ƒ๐Ÿ’ƒ๐Ÿ’ƒ

ES5

In script.js line 17, add arrow syntax? Check to see if there are any others

Few html suggestions

Screenshot 2019-08-09 at 09 22 46

Same screenshot as the last issue but don't forget to declare your language - I always like to put en-gb so that the computer knows it's proper English ๐Ÿ‡ฌ๐Ÿ‡ง

ALSO while I'm here in the html - you've not included a title.

And if I was you guys I would put the link to normalise above the style.css - I've had problems with this before, where normalise overrides changes in my style.css because I had placed it below in the html. Place above to make sure your changes override normalise!

It's fun to use

I know you teased me for saying this but it's actually really fun to play with so I'm going to say this again.

The little touches are really nice e.g. 'bearbug found on port 3000' and it actually feels like a really consistent project with the way it's branded etc.

Once you get the login page styled I think it's going to be really amazing

Empty files

I imagine that you some ideas to fill the empty files, right? If after the issues some are still empty, it might be good to delete them for having a clean repo?

Lack of visible labels

I wasn't sure what each input field was for, perhaps visible labels can clarify what the user is supposed to type; Nice work on the aria labels though :)

Heroku build

CSS doesn't appear to be loading on Heroku app, works locally though

Bear.png

Do you use both of them? Get rid of one?

npm start failed to run

It might just be me being inept, but I couldn't get your repo to run on local host.

Have taken screenshots of the error messages in case this is an actual problem and it's helpful in any way.

P.S. Yes, I did run npm i when I downloaded your repo.

Screenshot 2019-08-09 at 09 40 22

Screenshot 2019-08-09 at 09 40 13

Deployment

Your project is deployed on heroku and working with the DB! Congrats! ๐Ÿ…

getUD function(query file not passing correct response back to handler)

In handler.js line 110-124, getUD is being called, but dbPassword was not what you were expecting it to be(hashed password from the database).

getUD(username, password)
      .then(dbPassword => {
        console.log(dbPassword);
      })
      .then(result => {
        if (result == false) {
          console.log(result);
        } else {
          res.writeHead(301, {
            Location: "/",
            "Set-Cookie": `jwt=${cookie}`
          });
          res.end();
        }
      });

i took a look at where getUD is defined(getUD.js),
and you're resolving the promise with the response that comes back from the sql query.
this response is always a massive object, and your password is actually hidden inside the .rows property of this object, which is an array with objects inside it that represent the rows returned by your sql query.

const getUD = (username, password) => {
  return new Promise((resolve, reject) => {
    dbConnection
      .query(`SELECT password FROM login WHERE username= '${username}';`)
      .then(dbPassword => {
        // passwordHandling.comparePasswords(
        //   dbPassword[1],
        //   dbPassword[0][0].password
        // );
        resolve(dbPassword);
        console.log("dbPassword:", dbPassword);
        // console.log(dbPassword[1], dbPassword[0][0].password);
      })
      .catch(err => reject(err));
  });
};

dbPassword here isnt your database password, its an object with the value you want nested inside ๐Ÿ˜„
I've rewritten this to access the password and use it to resolve the response.

const getUD = (username, password) => {
  return new Promise((resolve, reject) => {
    dbConnection
      .query(`SELECT password FROM login WHERE username= '${username}';`)
      .then(sqlresponse => {
        console.log('response from password sql query', sqlresponse);
        //this is a massive object and you want the .rows property
        console.log('password is: ',sqlresponse.rows[0].password);
        resolve(sqlresponse.rows[0].password);
      })
      .catch(err => reject(err));
  });
};

Limit inputs

In the SQL build file, there are character limits on username and password, but no limit on the login inputs. You can easily add this with a maxlength in the input field like:
<input type="text" maxlength="30" id="username">

Great Idea

I love the idea. Have gained much catharsis already from submitting my bugbears ๐Ÿ› ๐Ÿป ๐Ÿ’ก

A guest review

"When I visited the site, I was pleased to note that I would not have to give up my personal information in order to enter. I had a highly pressing thought to offload and the ability to do so without being hindered by logging in was a pleasant element of my visit. 10/10 would recommend."

Anonymous visitor

setToken Function

One way of fixing this:

This bit

getUD
      .getUD(username, password)
      .then(dbPassword => {
        console.log(dbPassword);
      })

Like you say returns an object. To get the password and run the compare function in bcrypt you can try and return dbPassword.rows from the getUD.js. You can then iterate through the response like this:

response.rows[0][password] 

which will get this part of the object:

rows:
   [ { password:
        '$2b$10$a9/KgpWGLJ6DhuT5fKExqegKc8tRdCMhWTO34gRIrAeycKHoolPLO' } ],

User Journey?

You have a good description of your idea on your README but there is a lack of a specific user journey. This is one of the requirements for this week and I think would be easy for you to add on.

styling

Looking forward to some front end action :D and styling

User posts as logged-in user

I feel it would make sense, once you're logged in, that you'd post as the signed-in user โ€“ rather than being able to pick your name again. Maybe try and store the username in the cookie?

simpler Pool (bonus)

fun fact you don't actually need the options object - all of the data is already stored in your database url:

let connectionString = process.env.DATABASE_URL;
// this variable must be called 'connectionString' for this to work
module.exports = new Pool({
  connectionString,
  ssl: !connectionString.includes("localhost")
})

(Almost) even commits!

Three of the members of the team have equal commits and one has a couple extra. When addressing issues you could level this out. ๐Ÿฅ‡

getUD.js query

So close to getting the compare passwords bit done before the code review, which is great stuff!

const getUD = (username, password) => {
  return new Promise((resolve, reject) => {
    dbConnection
      .query(`SELECT password FROM login WHERE username= '${username}';`)
      .then(dbPassword => {
        // passwordHandling.comparePasswords(
        //   dbPassword[1],
        //   dbPassword[0][0].password
        // );
        resolve(dbPassword);
        console.log("dbPasswod:", dbPassword);
        // console.log(dbPassword[1], dbPassword[0][0].password);
      })
      .catch(err => reject(err));
  });
};

You'll want to import in your hashPassword function from passwordHandling.js to hash the password you've passed as a paramater in line 4. Remember your hashPassword function returns a promise, so you might need a .then() to find the hash! Compare this hash to dbPassword and you should be golden.

PS. I think you'll need to resolve true or false, rather than resolving the password.

security

:D Good! Intruders scripts don't run :)

Hashed

Nice hashed passwords
hash

Redirect on register

It should be relatively easy to re-direct to the main page when the user registers.

Accessibility

Your page could be made accessible quickly and easily by addressing two issues:

  • Add a title
  • Add labels for your inputs

const

Use const whenever the value isn't reassigned e.g. most function

Set a JWT in your guest logic

Handler.js, lines 164-167:

function guestLogic(req, res){
  res.writeHead(302, { Location: "/", 'Set-Cookie': 'logged_in=false' });
  res.end();
}

Because you're not setting this as a JWT you can end up with two cookies, one for being a guest and one for being logged in:

Screenshot 2019-08-16 at 10 33 51

It's amazing that you've managed to get the JWTs to work for the login route; it might be easier if you add this to the guest route too so there are no bugs later down the line.

Sanitise inputs

Looks like a user tried to make their post into an h1 to draw attention to their bugbear! ๐Ÿ‘ฟ

You seem to be sanitising the inputs so that this cannot be done. I tried to work out how you had done this but couldn't see it in your code. Could you explain this in your presentation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.