The course is part of this learning path
In this course, we will learn the concepts of microservice and spring framework with a focus on Spring Boot.
Learning Objectives
- Understanding Spring Boot
Intended Audience
- Beginner Java developers
- Java developers interested in learning how to Build and Deploy RESTful Web Services
- Java Developers who want to develop web applications using the Spring framework
- Java Developers who want to develop web applications with microservices
- Java Developers who wish to develop Spring Boot Microservices with Spring Cloud
Prerequisites
- Basic Java knowledge
Hello, dear friends. In this video, we will conduct the last login operations and attempt to log in to our project. Let's get started. First, I want to add an index HTML page. Add a new HTML named index. As you remember, we have defined this page in the WebConfig class. This page will be our main page. On this page, I will only redirect the page to the Login page. I need an a tag. In this we will set a log in to be action. Okay, done. If you want we can add a welcome message as well.
This will be enough as the localhost 8090 port will redirect us to this index page. Now, oen WebConfig. As you remember, we had defined a message source in this class. Let's use this in the Login page. Open the Login page. Open AdminLayout.
Open the Login page. Under the form, let's add a div. Add a row. Now, we can check error with th:if, th:if="&{param.errors}". Now we can show an alert. Message will be invalid password or email. Let's add another alert for logout. This will be enough. If we try to run this project, tables in MySQL will be generated. Let's try, run project, our project is now up and running. Launch any web browser. We can run our project using the local host URL, let's try. Look now we're on the index page, done.
I will add some data to my project for users. As previously said, I do not need to create user registration pages. I will manually add users because this page will only be used by two people. Let's add this with data.sql. Right click on 'Resources' and add a new SQL file. Now we can define our SQL scripts. First, persistent logins. Now, I will add roles to my table, insert into roles ADMIN, USER. Now let's add users. As you may recall, we defined a crypt, so I'll add an encrypted password. I'll need a password generator for this. In the test package, I will add a new class, name will be the PasswordGenerator.
Now, in main first we need a BcCyptPasswordEncoder. Now we need a password, for example, 12345. Now encode. After this, we can show it on the console. Let's run. Look, this is the equivalent of 12345, copy this, change with 12, run again. Look, the text was changed. I want to use 12345. Run again, copy. Now let's turn back data.sql. Let's insert the user, admin. Now paste the password. Now copy for the employee. Let's define another employee. Okay, done. Also, we have to fill the user_role table. First ID is the user_id, second is role_id. Done, these insert scripts must only be run once.
Therefore, we will delete them after running the project. Open AdminLayout, adjust the menu action. Done, now we can try, run project. Now open any browser, set URL as localhost:8090. Look, now we're on the Index page. Go to the Login page. First, try with the admin user. Look, we're on the Admin homepage, log out. Now try with the employee. As you can see, Employee homepage. Log out again. Try with a wrong email. Look, we could see the error alert. All right, done. We have now completed the login process. Let's take a little break here and we'll continue with product operations in the following video. I'll see you there.
OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.