Skip to content

Commit

Permalink
Merge pull request #21 from munhyunji/devlop
Browse files Browse the repository at this point in the history
관리자 로그인 시 세션 생성 및 리다이렉션
  • Loading branch information
munhyunji authored Jan 30, 2024
2 parents df12584 + a44f972 commit 7714799
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 32 deletions.
23 changes: 18 additions & 5 deletions FarmFind/src/main/webapp/WEB-INF/views/admin/inc/header.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:set var="path" value="${pageContext.request.contextPath }"/>
<c:set var="isme" value="dlwlrma2341" />

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
Expand All @@ -22,16 +23,28 @@
<link
href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
rel="stylesheet">


<script type="text/Javascript" src="${path}/resources/js/jquery-1.8.2.js"></script>
<script type="text/Javascript" src="${path}/resources/js/jquery-ui.js"></script>
<script type="text/Javascript" src="${path}/resources/js/jquery-ui.touch.js"></script>

<!-- Custom styles for this template-->
<link href="${path}/resources/css/sb-admin-2.css" rel="stylesheet">
<!-- Custom styles for this page -->
<link href="${path}/resources/vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">

<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>


</head>
<script>
//let apiurl = "http://localhost:8090/";
let apiurl = "https://farmfindapi.store:8090/";
$(document).ready(function(){
let userId = sessionStorage.getItem("id");
let confirm = '${isme}';
if(userId === '' || userId === null || userId != confirm) {
alert("로그인페이지로 이동합니다.");
location.href='${path}/admin/login';
sessionStorage.clear();
}
})
</script>
56 changes: 32 additions & 24 deletions FarmFind/src/main/webapp/WEB-INF/views/admin/itemList.jsp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

<%@ include file = "../inc/header.jsp" %>
<%@ include file = "./inc/header.jsp" %>

<body id="page-top">

<!-- Page Wrapper -->
Expand Down Expand Up @@ -132,6 +133,9 @@
<script src="${path }/resources/js/demo/datatables-demo.js"></script>

<script>
let userId = sessionStorage.getItem("id");
let session = '${isme}';
$(document).ready(function(){
Expand Down Expand Up @@ -265,30 +269,34 @@
//S3에 이미지 업로드
function submitForm(Aftimgfile, Nigimgfile, itemNo, imgId) {
var formData = new FormData(); // 새로운 FormData 객체 생성
formData.append('itemAft', Aftimgfile); // 낮이미지
formData.append('itemNig', Nigimgfile); //
formData.append('item_no', itemNo); // 파일 데이터 추가
// console.log("Aftimgfile"+Aftimgfile, "Nigimgfile:"+ Nigimgfile, itemNo);
$.ajax({
url: apiurl+'img/upload',
type: 'POST',
data: formData,
contentType: false,
processData: false,
success: function (data) {
// 서버로부터의 응답 처리
console.log(data);
imgUrlSavetoDB(data.filename, itemNo, imgId);
},
error: function (error) {
console.error('Error:', error);
}
});
if(userId == session) {
var formData = new FormData(); // 새로운 FormData 객체 생성
formData.append('itemAft', Aftimgfile); // 낮이미지
formData.append('itemNig', Nigimgfile); //
formData.append('item_no', itemNo); // 파일 데이터 추가
// console.log("Aftimgfile"+Aftimgfile, "Nigimgfile:"+ Nigimgfile, itemNo);
$.ajax({
url: apiurl+'img/upload',
type: 'POST',
data: formData,
contentType: false,
processData: false,
success: function (data) {
// 서버로부터의 응답 처리
console.log(data);
imgUrlSavetoDB(data.filename, itemNo, imgId);
},
error: function (error) {
console.error('Error:', error);
}
});
} else {
alert("관리자로그인 후 등록해 주세요");
}
}
//이미지 Url DB에 update
Expand Down
42 changes: 39 additions & 3 deletions FarmFind/src/main/webapp/WEB-INF/views/admin/login.jsp
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

<%@ include file = "./inc/header.jsp" %>
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:set var="path" value="${pageContext.request.contextPath }"/>

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<meta name="description" content="">
<meta name="author" content="">

<title>SB Admin 2 - Login</title>

<!-- admin-->
<link href="${path}/resources/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<link
href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
rel="stylesheet">

<script type="text/Javascript" src="${path}/resources/js/jquery-1.8.2.js"></script>
<script type="text/Javascript" src="${path}/resources/js/jquery-ui.js"></script>
<script type="text/Javascript" src="${path}/resources/js/jquery-ui.touch.js"></script>

<!-- Custom styles for this template-->
<link href="${path}/resources/css/sb-admin-2.css" rel="stylesheet">

</head>
<script>
//let apiurl = "http://localhost:8090/";
let apiurl = "https://farmfindapi.store:8090/";
</script>

<body class="bg-gradient-primary">

Expand Down Expand Up @@ -84,7 +117,10 @@
processData: false,
success : function(data) {
if(data == "Ok") {
sessionStorage.setItem("id", adminId);
location.href="${path}/admin/main";
} else {
alert("비밀번호가 올바르지 않습니다.");
return false;
Expand Down

0 comments on commit 7714799

Please sign in to comment.