- Fixed bug where main page wouldn't show user id
- Moved conditional behavior for showing user info OR showing login link into a higher-order component
- Got
getCurrentUser
request and handling working - Added tests for jwt behavior in
getCurrentUser
- Added
getCurrentUser
function to the client to send a request for user data on page load if token is present. This feature is not yet fully functional. - Added a corresponding route on the server side.
Goals:
- Preserve session after page reloads (with localStorage? Other solutions?)
- Guard routes with higher-order components
- Show appropriate errors for bad sign-in attempts
Accomplishments:
- Didn't add new code. Learned some stuff about how auth may be intended to work.
- Get app setup and running
- Add .env file
- Run database setup commands
- Run tests
- Review what specific tests are running
- Talk through learning your way around an unfamiliar web application
- Look in the
package.json
file to learn what tools/technology you're using (or whatever similar package manager-generated file exists depending on what language and framework you're working with, e.g. Gemfile for Ruby, mix.exs file for Elixir, etc) - Look for a "routes" or "router" file to see what pages and actions are available to the user
- Look for a database schema file or a set of migrations (or both) to see what kinds of objects we're storing data on
- Look in the
- Discuss the degree to which this strategy for learning your way around apps should hold for various technologies (should be at least fairly similar across most MVC web apps)
-
Spend a long time figuring out what we forgot when wiring up redux-form
-
Complete SignUp component
- but no form validation
-
Complete sign out action and reducer case
-
Still to do:
- Use a HOC to protect components that require authentication (see Stephen Grider's advanced react Udemy course)
- Allow login to persist even after refresh (ditto on Udemy course)
- Create all the other views / functionality (great React/Redux practice!)
-
Complete SignIn component
- create an Input component for redux-form Field
- enable cors on the server
-
Update router so landing page doesn't show on other pages.
-
WIP: start SignUp component
- Create component (close copy of the SignIn component)
- Create signUpUser action
-
Tomorrow:
- fix bug in signUpUser action where it's not sending data to server
- form validation on signUp form
- Epic battle with
react-router
,history
,react-router-dom
,redux-form
, semver. - Finally upgraded to latest version (4.x) of everything, and updated code accordingly.
- To do tomorrow: use Field component instead of to take advantage of
redux-form
/ use latest version ofredux-form
properly
- Review code that was hastily copied and pasted on Friday
- Update SignIn component to display errors without using clarityui (including creating
error-alert
style) - Update SignIn to bind handleFormSubmit in the constructor
- Create browser history using
history
npm module - Started signIn infrastructure:
- component
- actions
- reducer
- route
- Updated (started?) user component
- component
- route
- Start React!
- Use Di's boilerplate: [http://github.com/DianaVashti/react-webpack-materialui-boilerplate.git]
- Add Redux
- Make Header component
- Protect
PATCH /posts/:id
(including checking for correct user) and test - Ditto for
DELETE /posts/:id
-
YouTube link to recording (warning: screen not shared for part of it!)
-
Add jwt middleware for route authentication
-
Protect
PATCH /users/:id
route and test- Test for requests without jwt
- Test for request with user that doesn't match jwt
-
Protect
POST /posts
route and test
-
Make sign-up route:
/auth/sign-up
- Return either error if bad user info
- blank email / password
- email already in use
- Or return jwt if user created
- Return either error if bad user info
-
Write tests for
/auth/sign-up
-
Discuss mutable objects and why you have to be careful with them
-
Discuss testing philosophy and the balance between completeness vs. wasted effort
- Add tests for
checkUserLogin
- Add tests for
/auth/sign-in
route - Update
checkUserLogin
to return user on success - Add code to generate token on sign-in
- Revive
getUserByEmail
from previous git commits (it had been changed intogetUserById
) - Finish
checkUserLogin
(it was there but woefully incomplete) - Create files for the passport strategies (
services/passport.js
) and authentication route functions (controllers/authentication.js
) - Create
/auth/sign-in
route with passport local strategy middleware - Started the server, worked out some kinks with
dotenv
- Try to test
/auth/sign-in
using postman; realized we don't have anyone in our production database whose password we know. Will test tomorrow.
- Update deletePostById to return
null
when id doesn't exist - Create
DELETE /posts/:id
route and tests - Create
POST /posts
route and tests
- Change PUT to PATCH for
/users/:id
- Fix tests for PATCH
/users/:id
(check for returns!!) - Add routes and tests for GET and PATCH
/posts/:id
- Merged Dev's changes from Thursday
- Started PUT
/users/:id
route and tests
- Changed
getUser*ByEmail
togetUser*ById
- Implemented GET
/users/:id
route and tests
- Added routes files and test files
- Created tests and functionality for
/cities/:id
route
- Complete tests for
getPostsByCityId
- Complete tests and functions for
getCityDataById
- Start writing express server (instantiate express)
- Fix
update*ById
tests so thatbeforeEach
doesn't clobberbefore
- Changed name of
getUserData
andgetPostById
togetUserDataByEmail
andgetPostDataById
(respectively) for consistency - Started functions and tests for `getPostsByCityId
- Complete
updatePostById
function - Write tests and functions for
updateUserById
- Learn that mocha runs all the
beforeEach
functions after thebefore
functions, which caused problems with our tests
- completed tests for
updatePostById
and almost finished function
- Completed
deletePostById
(including tests). - Started to write
updatePostById
and tests
- Completed
getPostById
(including tests). - Started to write
deletePostById
and tests
- Started going faster through back end looking to start react
- Introduced async / await
- Finished
getUserData
; startedgetPostsByUserId
- Discovered that abstracted property tests function wasn't actually running the tests; un-refactored.
- Created some tests for
getUserData
-- property set tests and values for some of the properties
- Discussed why Bonnie prefers one
expect
per test - Refactor property tests to make more DRY
- Abstract out property tests into a function
- now can be used in multiple tests
- if we change to test in a different way it will affect all tests
- Discussed integration vs. unit tests and stub/mock
- Start to write tests and code for
getUserData
- Discussed possible options for testing
getUserByEmail
:- Test for existence of each property individually
- Create an object that represents all expected properties and values and do a "deep equal"
- Create a set of properties, and a set of expected properties, and compare.
- Decided on (and coded) option 1
- Researched
bcrypt
vsbcryptjs
; decided on the latter - Completed
encryptPassword
andcomparePassword
functions inpassword.js
- Added test to check that password was encrypted properly
- Discussed testing functions that return promises (and how easy it is to get false positives)
- harped on using JSDoc
- Started to create getUserData, realized we needed getUserByEmail
- refused to use chai includes despite Kelcey's best efforts
- WIP: created tests for getUserByEmail
- got stuck on comparing the object returned by the success case
- will resume tomorrow by doing deepEqual using known userRow
- this will involve giving user fixed "joined_at" data
- export user data from db_reset so code is DRY and there's less chance for discrepancies
- Implemented mocha.opts
- Researched
--exclude
option for mocha, which was implemented 16 days ago and has not yet been merged: mochajs/mocha#3210 - Create tests and functionality for addUser action (without encrypted password)
- Start to create and employ password ecryption function
- Complete seed function in
db_reset.js
- Research best way to use
dotenv
with multiple test files - Start to implement
mocha.opts
- Create
db.js
file - Start setting up for db testing
- create
db_reset.js
file - create functions to truncate all tables
- start function to seed db
- create
- Create file structure
- Brainstorm actions
- Decided to create comment actions later
- Start to fill out file structure for the project
npm init
andnpm install
dependencies- Write
db:
npm scripts - Discuss
.env
vs shell scripts to create env variables- variables from the latter can be used in
package.json
scripts
- variables from the latter can be used in
- More data modeling
- Decided to let user enter arbitrary string for primary city, rather than associating it with a city id in the cities table.
- Discussed TEXT vs. VARCHAR (see this article)
- Discussed how to disallow empty string
- Complete lists of views and routes
- List and decide on express modules
- Research/discuss
cookie-session
vs.express-session
vs.client-sessions
- Research/discuss
passport
andbcrypt
- Research/discuss
- Start data modeling
- Read Module
- Create git repo and github repo
- Start to brainstorm architecture