include/header.jsp
페이지 정보
본문
<%@ 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="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Model2 MVC 패턴</title>
<link rel="stylesheet" href="/css/basic.css">
<script src="http://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.4.1.min.js"></script>
</head>
<body>
sessionScope.id : ${sessionScope.id }<br>
sessionScope.name : ${sessionScope.name }<br>
sessionScope.level : ${sessionScope.level }<br>
<table width=100% height=50>
<tr>
<td><a href="/">[로고]</a></td>
<td align="right">
<c:if test="${sessionScope.level eq '10' }">
<a href="/admin/">[관리자]</a>
</c:if>
<a href="/chat.jsp">[채팅]</a>
<a href="/mail.jsp">[메일]</a>
<c:choose>
<c:when test="${sessionScope.id != null }">
<span onclick="kakaoLogout()" style="cursor:pointer">[카카오 로그아웃]</span>
<a href="/member/logout">[로그아웃]</a>
<a href="/member/modify">[회원수정]</a>
</c:when>
<c:otherwise>
<span onclick="kakaoLogin()" style="cursor:pointer">[카카오 로그인]</span>
<a href="/member/login">[로그인]</a>
<a href="/member/join">[회원가입]</a>
</c:otherwise>
</c:choose>
</td>
</tr>
</table>
<hr>
<!-- 카카오 스크립트 -->
<script src="https://developers.kakao.com/sdk/js/kakao.js"></script>
<script>
Kakao.init('eacf4492b3e5e7837316dc675729....'); //발급받은 키 중 javascript키를 사용해준다.
console.log(Kakao.isInitialized()); // sdk초기화여부판단
//카카오로그인
function kakaoLogin() {
Kakao.Auth.login({
success: function (response) {
Kakao.API.request({
url: '/v2/user/me',
success: function (response) {
console.log(response); //회원정보 객체
console.log("식별 아이디:"+response.id);
console.log("이메일:"+response.kakao_account.email);
//회원가입 처리 및 세션 처리
$.ajax({
url: "/member/kakao",
type: "get",
dataType: "text",
data: "useremail="+response.kakao_account.email,
success:function(num){
//추가 내용 작성
location.href="/"; //첫 페이지로 이동
}
});
},
fail: function (error) {
console.log(error)
},
})
},
fail: function (error) {
console.log(error)
},
});
}
//카카오로그아웃
function kakaoLogout() {
if (Kakao.Auth.getAccessToken()) {
Kakao.API.request({
url: '/v1/user/unlink',
success: function (response) {
console.log(response);
//로그아웃 세션 삭제후 첫 페이지 이동
$.ajax({
url: "/member/kakaoLogout",
type: "get",
dataType: "text",
success:function(num){
console.log(num);
//if(num == 'kakaoLogout'){
location.href="/";
//}
}
});
},
fail: function (error) {
console.log(error);
},
})
Kakao.Auth.setAccessToken(undefined);
}
}
</script>
- 이전글회원 테이블( member ) 수정 24.04.09
- 다음글model/Member.java 24.04.09
댓글목록
등록된 댓글이 없습니다.