jpablog : security login, jsp taglib
This commit is contained in:
@@ -21,10 +21,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
@@ -51,18 +51,18 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>-->
|
||||
</dependency>
|
||||
|
||||
<!-- 시큐리티 태그 라이브러리 -->
|
||||
<!--<dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-taglibs</artifactId>
|
||||
<version>5.4.2</version>
|
||||
</dependency>-->
|
||||
</dependency>
|
||||
|
||||
<!-- JSP 템플릿 엔진 -->
|
||||
<dependency>
|
||||
|
||||
@@ -19,7 +19,6 @@ import javax.servlet.http.HttpSession;
|
||||
public class UserApiController {
|
||||
|
||||
private final UserService userService;
|
||||
private final HttpSession session;
|
||||
|
||||
@PostMapping("/user")
|
||||
public ResponseDto<Integer> save(@RequestBody User user) {
|
||||
@@ -28,12 +27,13 @@ public class UserApiController {
|
||||
return new ResponseDto<>(result, HttpStatus.OK.value());
|
||||
}
|
||||
|
||||
/*// 기본 로그인
|
||||
@PostMapping("/user/login")
|
||||
public ResponseDto<Integer> login(@RequestBody User user) {
|
||||
public ResponseDto<Integer> login(@RequestBody User user, HttpSession session) {
|
||||
User principal = userService.로그인(user);
|
||||
if (principal != null) {
|
||||
session.setAttribute("principal", principal);
|
||||
}
|
||||
return new ResponseDto<>(1, HttpStatus.OK.value());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
||||
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
|
||||
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<sec:authorize access="isAuthenticated()">
|
||||
<sec:authentication property="principal" var="principal"/>
|
||||
</sec:authorize>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -13,7 +16,6 @@
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
|
||||
<a class="navbar-brand" href="/">블로그</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
|
||||
@@ -21,7 +23,7 @@
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="collapsibleNavbar">
|
||||
<c:choose>
|
||||
<c:when test="${empty sessionScope.principal}">
|
||||
<c:when test="${empty principal}">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/loginForm">로그인</a>
|
||||
|
||||
Reference in New Issue
Block a user