formatting

This commit is contained in:
nkchauhan003
2022-12-15 16:16:47 +05:30
parent 267972e472
commit 42a05bda49
7 changed files with 122 additions and 124 deletions

162
pom.xml
View File

@@ -1,85 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.cb</groupId>
<artifactId>spring-security-form-login</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-security-form-login</name>
<description>Spring Security + Thymeleaf + MySql</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.cb</groupId>
<artifactId>spring-security-form-login</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-security-form-login</name>
<description>Spring Security + Thymeleaf + MySql</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -51,6 +51,4 @@ public class LoginController {
userService.saveUser(userDto);
return "redirect:/registration?success";
}
}

View File

@@ -1,7 +1,6 @@
# JPA
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
# Connection Pool
spring.datasource.hikari.connection-timeout=20000
spring.datasource.hikari.minimum-idle=10
@@ -9,7 +8,6 @@ spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.idle-timeout=10000
spring.datasource.hikari.max-lifetime=1000
spring.datasource.hikari.auto-commit=true
# MySql
spring.datasource.url=jdbc:mysql://localhost/spring-security-form-login
spring.datasource.username=root

View File

@@ -2,9 +2,9 @@
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<meta content="width=device-width, initial-scale=1" name="viewport">
<link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" rel="stylesheet">
<title>Login</title>
</head>
@@ -20,22 +20,24 @@
<div class="alert alert-success">You have been logged out !!!</div>
</div>
<form
class="form-horizontal"
method="post"
role="form"
th:action="@{/login}"
class="form-horizontal"
>
<div class="mb-3">
<label for="password" class="form-label">Email</label>
<input type="email" class="form-control" id="username" name="username" placeholder="Enter email address">
<label class="form-label" for="password">Email</label>
<input class="form-control" id="username" name="username" placeholder="Enter email address"
type="email">
</div>
<div class="mb-3">
<label for="password" class="col-sm-2 col-form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Enter password">
<label class="col-sm-2 col-form-label" for="password">Password</label>
<input class="form-control" id="password" name="password" placeholder="Enter password"
type="password">
</div>
<div class="mb-3">
<button type="submit" class="btn btn-primary mb-3">Login</button>
or <a th:href="@{/registration}" class="link-primary">Register</a>
<button class="btn btn-primary mb-3" type="submit">Login</button>
or <a class="link-primary" th:href="@{/registration}">Register</a>
</div>
</form>
</div>
@@ -43,9 +45,9 @@
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
<script crossorigin="anonymous"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@@ -2,9 +2,9 @@
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<meta content="width=device-width, initial-scale=1" name="viewport">
<link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" rel="stylesheet">
<title>Registration</title>
</head>
@@ -25,26 +25,26 @@
</div>
</div>
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name" name="name">
<p th:errors="*{name}" class="text-danger"
<label class="form-label" for="name">Name</label>
<input class="form-control" id="name" name="name" type="text">
<p class="text-danger" th:errors="*{name}"
th:if="${#fields.hasErrors('name')}"></p>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" name="email">
<p th:errors="*{email}" class="text-danger"
<label class="form-label" for="email">Email</label>
<input class="form-control" id="email" name="email" type="email">
<p class="text-danger" th:errors="*{email}"
th:if="${#fields.hasErrors('email')}"></p>
</div>
<div class="mb-3">
<label for="password" class="col-sm-2 col-form-label">Password</label>
<input type="password" class="form-control" id="password" name="password">
<p th:errors="*{password}" class="text-danger"
<label class="col-sm-2 col-form-label" for="password">Password</label>
<input class="form-control" id="password" name="password" type="password">
<p class="text-danger" th:errors="*{password}"
th:if="${#fields.hasErrors('password')}"></p>
</div>
<div class="mb-3">
<button type="submit" class="btn btn-primary mb-3">Register</button>
or <a th:href="@{/login}" class="link-primary">Login</a>
<button class="btn btn-primary mb-3" type="submit">Register</button>
or <a class="link-primary" th:href="@{/login}">Login</a>
</div>
</form>
</div>
@@ -52,9 +52,9 @@
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
<script crossorigin="anonymous"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@@ -2,9 +2,9 @@
<html lang="en" xmlns:sec="http://www.thymeleaf.org/extras/spring-security" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<meta content="width=device-width, initial-scale=1" name="viewport">
<link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" rel="stylesheet">
<title>User</title>
</head>
@@ -16,15 +16,15 @@
<div class="mt-2">Username: <span sec:authentication="principal.username"/></div>
<div class="mt-2"> Roles: <span sec:authentication="principal.authorities"/></div>
<div class="mt-5"><a th:href="@{/logout}" class="link-primary">Logout</a></div>
</div>
</div>
<div class="mt-5"><a class="link-primary" th:href="@{/logout}">Logout</a></div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
<script crossorigin="anonymous"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@@ -6,8 +6,8 @@ import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ApplicationTests {
@Test
void contextLoads() {
}
@Test
void contextLoads() {
}
}