본문 바로가기
창고 3/[Dev] My Readme

몽고 DB 기초 5

by 부엉이의 정보 창고 2022. 1. 10.
728x90

Login and Hash

Checking user info in collection(before password hashing

User password after hashing

User login failed with wrong password

Token

With json web token npm library, a token is created like below.

const token = jsonWebToken.sign(user._id.toHexString(), 'myToken')
  • Client : setting the token into cookie
  • Server : setting the token into database

Configuration

During connecting MongoDB using mongoose/express, database info such as username and password is required and can be seen in codes. Also, sensitive information such as API key should not be displayed in public neither. Thus, environment variable/file is needed to manage that.

// Environment variable in Node.js
// The process.env property returns an object containing the user environment.
process.env // global object. approachable in whole application. 
728x90

'창고 3 > [Dev] My Readme' 카테고리의 다른 글

Node js 기초 1  (0) 2022.01.12
몽고 DB 기초 6  (0) 2022.01.11
몽고 DB 기초 4  (0) 2022.01.07
몽고 DB 기초 3  (0) 2022.01.06
몽고 DB 기초 2  (0) 2022.01.05

댓글


loading