So we have our post log in or a post show log in handler that will allow us to validate whether someone
is actually in the database, has the correct username, which is an email address and has the correct
password.
But we don't have any information in our database.
So if I look at the table users and I'll show you using postal code, but you can use DB or whatever,
whatever client you want.
This is my users table and it's currently empty and I can easily enough add someone so I can put myself
in here.
Trevor.
My email will be me or I'll call it admin at admin dot com.
Here's the problem.
Password.
What am I going to put in for password?
Because I'm not storing clear text passwords because that's a serious violation of good security.
So I need some means of generating a hash from a valid password.
How am I going to do that?
Well, let's fill out the rest of this stuff first.
I'll make my access level three, which I've arbitrarily decided is going to be the admin level of access
and created that I'll put in some date.
There's one.
But I still need some means of putting a password in there.
Well, it's actually pretty easy.
And what I'm going to do is take you to some code that I've written and saved on Play Langue, which
is a nice place where you can actually enter short programs and run them right from a Web browser.
And you'll see here that I've created a very simple program that has just package making and it has
to import the format package and this one decrypt, which we're using already in our code.
And all I'm doing is specifying a password as a string variable.
And I've used arbitrarily the password password, by the way, don't use the password password in production.
It's a bad idea, but I just want to get this running and then I'm using the secret package to actually
generate a hash from a password.
It takes two parameters.
The first one is the is is a slice of bytes and I'm just taking my string password and in passing that
in as a slice of bytes and the second parameter will generate the level of complexity for the hash.
And then I'm just pointing it out.
So when I run this.
I actually get a hashed password, so I'll copy that, oops, get the whole thing here.
Copy it.
Go back to my database editor and paste that password in.
And then save changes and now I have an entry in the database that I can actually use to test validation
when we log in to test whether or not someone has entered the correct password.
So I've put a link to the actual play this code on played go on the course resources, or you can just
type this out in your favorite text editor and run it on your local machine.
It's entirely up to you.
So we'll test the newly added user in the database in the next lecture.