Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
In this video we add the ability to associate an added task with the currently signed in user. We also discuss the importance of storing encrypted passwords and add a password encoder to our application.
BCrypt Password Hashing
BCrypt is a hashing function that is based on the Blowfish cipher. It is designed to allow the ability to be iteratively applied a specified number of times (referred to as the cost parameter). One advantage of this hash is that, as processors get faster and servers have the ability to process more requests concurrently, the number of iterations can be increased so that a "brute-force" attack can be slowed to the point of detection before the attack is successful.
- https://en.wikipedia.org/wiki/Bcrypt
- https://en.wikipedia.org/wiki/Blowfish_(cipher)
- BCryptPasswordEncoder
Injecting User Data for Modifying Queries
If you want to inject user-specific data using the authentication object for INSERT statements, in the same way that we did for SELECT statements, you'll need to use a native query. Here is an example of a Spring Data JPA interface method that you could use:
@Modifying
@Transactional
@Query(nativeQuery = true, value = "insert into task (user_id,description,complete) values (:#{principal.id},:#{#task.description},:#{#task.complete})")
void saveForCurrentUser(@Param("task") Task task);
Git Command to Sync Your Code to the Start of this Video
git checkout -f v7
Using Github With This Course
You can complete this course entirely using code created by you on your local machine. However, if you choose to use the code I've made available to you, you have two options:
- Use the project files linked at the bottom of this page, or
- Use the Github repository I've made available (recommended)
If you choose the recommended option of using the Github repository, it can be found at
https://github.com/treehouse/todotoday
To utilize Github with this course, you can download the Github desktop client for your system or use the command line interface provided with Git.
Clone this repository to your machine using the Github desktop client, or using the following command:
git clone git@github.com:treehouse/todotoday.git
To update your local repository to match a video's starting point, you can use the git checkout
command in combination with the stage and video number. For example, to update your local repository to match the starting point of Video 4, you'd use the following:
git checkout -f v4
Notice the use of the -f option. This forces Git to override all local changes, so be aware: this will cause any changes you made to be lost.
You need to sign up for Treehouse in order to download course files.
Sign up