Skip to content
Snippets Groups Projects
Commit 8e143409 authored by M2kishore's avatar M2kishore
Browse files

added login

parent aedc12f4
No related branches found
No related tags found
No related merge requests found
package com.example.bookmanagement; package com.example.bookmanagement;
import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
......
...@@ -2,6 +2,7 @@ package com.example.bookmanagement; ...@@ -2,6 +2,7 @@ package com.example.bookmanagement;
import java.util.List; import java.util.List;
import com.example.bookmanagement.error.BookIdMismatchException;
import com.example.bookmanagement.error.BookNotFoundException; import com.example.bookmanagement.error.BookNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -10,6 +11,7 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -10,6 +11,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -22,7 +24,7 @@ public class BookController { ...@@ -22,7 +24,7 @@ public class BookController {
private BookRepository bookRepository; private BookRepository bookRepository;
@GetMapping @GetMapping
public Iterable findAll() { public Iterable<Book> findAll() {
return bookRepository.findAll(); return bookRepository.findAll();
} }
......
...@@ -14,6 +14,6 @@ public class SimpleController { ...@@ -14,6 +14,6 @@ public class SimpleController {
public String homePage(Model model) { public String homePage(Model model) {
System.out.println("qwerty"); System.out.println("qwerty");
model.addAttribute("appName", appName); model.addAttribute("appName", appName);
return "home"; return "index";
} }
} }
package com.example.bookmanagement.error; package com.example.bookmanagement.error;
public class BookIdMismatchException extends RuntimeException{ public class BookIdMismatchException extends RuntimeException{
/**
*
*/
private static final long serialVersionUID = 1L;
public BookIdMismatchException(String message, Throwable cause) { public BookIdMismatchException(String message, Throwable cause) {
super(message,cause); super(message,cause);
......
This diff is collapsed.
body {
padding-top: 40px;
padding-bottom: 40px;
background-color: #eee;
}
.form-signin {
max-width: 330px;
padding: 15px;
margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin .form-control {
position: relative;
height: auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
font-size: 16px;
}
.form-signin .form-control:focus {
z-index: 2;
}
.form-signin input {
margin-top: 10px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.form-signin button {
margin-top: 10px;
}
.has-error {
color: red
}
\ No newline at end of file
This diff is collapsed.
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org"
layout:decorate="~{fragments/layout}">
<head>
<title>Index</title>
</head>
<body>
<div layout:fragment="content" th:remove="tag">
<h1>Hello Spring Security</h1>
<p>This is an unsecured page, but you can access the secured pages after authenticating.</p>
<ul>
<li>Go to the <a href="/" th:href="@{/}">secured pages</a></li>
</ul>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org"
layout:decorate="~{fragments/layout}">
<head>
<title>Login</title>
</head>
<body>
<div layout:fragment="content" th:remove="tag">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1>Login page</h1>
<form th:action="@{/login}" method="post">
<div th:if="${param.error}">
<div class="alert alert-danger">
Invalid username or password.<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org"
layout:decorate="~{fragments/layout}">
<head>
<title>Login</title>
</head>
<body>
<div layout:fragment="content" th:remove="tag">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1>Login page</h1>
<form th:action="@{/login}" method="post">
<div th:if="${param.error}">
<div class="alert alert-danger">
Invalid username or password.
</div>
</div>
<div th:if="${param.logout}">
<div class="alert alert-info">
You have been logged out.
</div>
</div>
<div class="form-group">
<label for="username">Username</label>:
<input type="text"
id="username"
name="username"
class="form-control"
autofocus="autofocus"
placeholder="Username">
</div>
<div class="form-group">
<label for="password">Password</label>:
<input type="password"
id="password"
name="password"
class="form-control"
placeholder="Password">
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input type="submit"
name="login-submit"
id="login-submit"
class="form-control btn btn-info"
value="Log In">
</div>
</div>
</div>
</form>
</div>
</div>
<p><a href="/" th:href="@{/}">Back to home page</a></p>
</div>
</body>
</html>
</div>
</div>
<div th:if="${param.logout}">
<div class="alert alert-info">
You have been logged out.
</div>
</div>
<div class="form-group">
<label for="username">Username</label>:
<input type="text"
id="username"
name="username"
class="form-control"
autofocus="autofocus"
placeholder="Username">
</div>
<div class="form-group">
<label for="password">Password</label>:
<input type="password"
id="password"
name="password"
class="form-control"
placeholder="Password">
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input type="submit"
name="login-submit"
id="login-submit"
class="form-control btn btn-info"
value="Log In">
</div>
</div>
</div>
</form>
</div>
</div>
<p><a href="/" th:href="@{/}">Back to home page</a></p>
</div>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment