Skip to content

Commit

Permalink
feat: Add user information to index page
Browse files Browse the repository at this point in the history
  • Loading branch information
todyDev committed Nov 8, 2018
1 parent 117c952 commit 4c1ef38
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion securityPrj/src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %><%@ page import="org.springframework.security.core.context.SecurityContextHolder" %>
<%@ page import="org.springframework.security.core.Authentication" %>
<%
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String name = "";
if(auth.getPrincipal() != null) {
name = auth.getName();
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Expand All @@ -17,6 +25,7 @@
<h5><a href='<c:url value="/secu/loginPage"/>' class="badge badge-pill badge-info">LOGIN</a> 로그인 해주세요.</h5>
</sec:authorize>
<sec:authorize access="isAuthenticated()">
<h5><%=name %>님, 반갑습니다.</h5>
<form action="/logout" method="POST">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
<button type="submit" class="btn btn-dark btn-sm">LOGOUT</button>
Expand Down

0 comments on commit 4c1ef38

Please sign in to comment.