Hello, dear friends, in this video, we will make our user control operations, so let's begin.
Now, in our project, as you see here, we have pages and a previous video, I hope you remember that
we can access them when we give them.
You are all in the browser.
So first.
Let's open user static class.
Now, do you remember in a previous video for Quick Access, we added a standard user ID?
Well, that's why we added it.
But now, you know.
So let's just delete this, Heidi.
OK, so let's try it out.
All right, so as you can see, we're now on the login page, so let's change the URL with add category
page.
And we can access.
I was trying to add a new category.
Oh, see, there's year, so the reason for the air is that we don't have any user I.D. information
in the user static class because we set the user I.D. information to user static class after logging
operations.
Yeah.
So we have to check the user ID information.
And if the user ideas zero, well, this means that we've got a redirect page to the login page.
So for now, we're just going to add a new attribute.
So in the middle class, let's add a new folder and call it attributes.
Now, let's add our first attribute and new class name to login control.
Now, for a logging control, we have to drive this class from another attribute and the first one is
filter attribute.
And the second one is I action filter.
Now, the filter attribute is an abstract class and eye action is an interface and we can control our
cookies with the help of these elements.
So I said I action is an interface, and as you know, in using interfaces, we have to override interfaces
methods in this particular class.
So let's look at the interface.
Now we have to override these two methods.
On action executed, but we're not going to use this method now on action, executing now we want to
control on executing.
So we will use the second method.
And if you want to, you can control with cookies.
So for checking those cookies, we will write.
HTP context, current user identity is not authenticated.
And this basically means we didn't log in yet, so we will redirect to the log in page.
Filter context, htp, context, response, redirect.
And now just give the pat.
And that's a done.
So actually, you know what, this is going to be enough, but sometimes you might get an error for
the user ID.
So I do want to check whether the user is legitimate or not.
And, you know, for our particular program and this is going to be the definitive solution.
So let's just delete this area.
User Statik, user ID is zero done, so now we can use this attribute for each page, but in order to
make it easier, I just want to add a new controller.
Add new controller named base controller.
Now we can add our attribute into this controller.
So now let's derive the other controllers from the base controller, except the Log-in controller,
for example, Medha.
Or address.
Cool.
Now, let's try.
All right, so now in the U.S., let's right and address.
And here we are, we're on the log in page.
So now let's try to add category.
Now, look, we can access that category because we didn't adjust the category controller yet, right?
So let's go ahead and adjust the other controllers.
And that's done, so that means that in the admin area, all controllers will derive from the base controller.
So what do you think?
I think it's enough for now before we adjust the front pages of this site.
I do want to add all values to my database.
So in the next video, I will add Oak's data so that we can show it on the front page.
If you want to, you can skip the next video.
But I'd say stick around.
So I'll see you then.