Welcome back.
So now we're gonna create the function that will display the post login menu
for our logged in users with options. So
let us do that just above the function to view the logs. So right here,
I'm gonna say a function to display
post login menu.
OK?
All right. So as usual,
we're going to call this one, let's say post underscore login underscore menu.
I think that's a good name.
And of course, inside we're gonna pass in a parameter, username at a colon.
OK? So
we're gonna create a while statement. So while
the user is in fact logged in,
let us now print out the
options for them.
So first of all, I'm actually gonna print out
like a regular uh message. So I can say something like uh log in
uh I'm sorry, post login menu, right? Post dash login menu.
OK? And let me add my
backward slash N so that this is on a new line.
And OK. So now we can print out the options. There's only going to be two of them.
OK? So option number one will be to simply view
uh
my logs. Remember this is personalized it's for the logged in user.
And then option number two, well,
log out, I guess.
And there it is. So
we're gonna have to ask the user which option they want to go for. So
I'm gonna say choice equals and then input
and then we can say something like uh you know, what would
you like to do?
Question mark?
OK.
So now we're gonna have to create the el statements for each scenario. So
I'm gonna go with the first one. If
uh if choice equals one,
what they wanna do, wanna view the logs
and of course, the username. So we're gonna call in the function which is view logs,
user name. So very, very simple.
And then we can say L if choice
uh equals
uh
two
and then what do we want to do in here?
Well, we can simply print out
a message
that says logged
out successfully.
But then don't forget we want to log every
uh every task. So
we're gonna add the log event
statement in here.
So log events
and then we can say something like uh
if
F string and then
we can say user,
I have a collie braces
in single codes, user username, uh logged out
and there you go.
And of course,
don't forget we need the break set mentioned in case the logged in user decides to,
for some reason,
choose option 34 or five or any other option that doesn't exist So
we're gonna say break. And then else
you can just simply print out a message that says
uh invalid choice. Please try again.
And
there it is. OK. So
we have successfully now created the functional display the post login menu.
However,
how do we actually link it to the login function? Because once the user logs in,
we want to call this function. So
what do we do? We're gonna go over to the main login function.
And now let's look at the code where has the user logged in?
It says right here login successful.
So right here where it says the login successful,
I'm gonna come over here right now and now call our function.
So here I'm going to say post
underscore login underscore menu
and of course, in brackets, we're going to add the username
and
there you go. So
that's it. I think we have successfully finished writing our code.
Let's now test it out.
I'm gonna run the code.
OK?
And I am going to log in first of all as actually, you know what,
I'm going to try something else. OK? I'm just register
a new user.
Ok? And I'm going to call this user Boris. OK? And then password will be Boris
123 with the at symbol.
OK?
So now let Boris
log in. So Boris and then
bodies 123,
the add symbol
and there you go. Yes, we can see bodies. Now has the post login menu
and can bodies view his logs. We're gonna press one
and there you go logs for user bodies bodies successfully registered at 835.
And then he's successfully logged in at 8 1045.
And if we look at our users dot TXT, there you go. We have bodies
with his hash password.
And then over here we have the
Alex successfully registered John successfully logged in.
Obviously, these are
tests that I did off screen.
But you can see right now that the program is in fact working successfully.
There are a few other tests we can run. We can make sure
that if I typed in option number five in here,
ok,
I typed in five and I pressed enter,
it can say invalid choice. Please try again.
So let me try to log out now
and you can see it in fact
successfully logged out.
And if I press three
at the main menu,
you can see right now it has exited the
system and our program is in fact working properly.
So
there it is. Congratulations.
You have successfully created a pretty advanced user registration system
that would allow users to register.
We've also implemented a password checker to ensure
that the password is strong enough by having at least eight characters long,
having one uppercase letter one number and also a special symbol.
And of course,
we've also added additional security features to
hash the password so that they're stored
in a hashed format.
And of course,
we also created a post login menu for the logged in
users where they can then view their own personal logs.
That's it. It's been fun. Thank you so much for watching.
I will see you in the next class.