This commit is contained in:
hyunho 2020-11-25 07:04:00 +00:00
parent c844060b54
commit 6cececadd7
7 changed files with 192 additions and 83 deletions

View File

@ -844,6 +844,10 @@ namespace NP.FO.Controllers
{
return View();
}
public ActionResult KakaoCallback()
{
return View();
}
public String XPayVBankMoney()
{

View File

@ -669,6 +669,7 @@
<Content Include="Views\Course\XpayReturnURL.cshtml" />
<Content Include="Views\My\Document.cshtml" />
<Content Include="Views\Account\NaverCallback.cshtml" />
<Content Include="Views\Account\KakaoCallback.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />

View File

@ -1,4 +1,8 @@
@model NP.Model.VMUser
@{
var naverClientId = "fvaj0CdI04awGMEhaICy";
var kakaoAppkey = "7b09519e7bce67d548a2a594a48acf63";
}
<head>
<script type="text/javascript" src="/js/naveridlogin_js_sdk_2.0.0.js"></script>
<script type="text/javascript" src="/js/kakao.js"></script>
@ -101,21 +105,16 @@
}
var naverLogin = new naver.LoginWithNaverId(
{
clientId: "fvaj0CdI04awGMEhaICy", //개발자센터에 등록한 ClientID
callbackUrl: "https://www.ynicte.com/Account/NaverCallback",//개발자센터에 등록한 callback Url
isPopup: false, /* 팝업을 통한 연동처리 여부 */
loginButton: { color: "green", type: 3, height: 60 }, /* 로그인 버튼의 타입을 지정 */
clientId: "@naverClientId",
callbackUrl: "https://www.ynicte.com/Account/NaverCallback",
isPopup: false,
loginButton: { color: "green", type: 3, height: 60 },
}
);
function loginWithKakao() {
Kakao.Auth.login({
success: function (authObj) {
alert(JSON.stringify(authObj))
},
fail: function (err) {
alert(JSON.stringify(err))
},
Kakao.Auth.authorize({
redirectUri: 'https://www.ynicte.com/Account/KakaoCallback'
})
}
@ -124,11 +123,7 @@
}
function snsInit() {
// 카카오 SDK를 초기화 합니다. 사용할 앱의 JavaScript 키를 설정해 주세요.
Kakao.init('f30a121bf140bf3d3dbf72012b7d713c');
// SDK 초기화 여부를 판단합니다.
console.log(Kakao.isInitialized());
/* 네이버 설정정보를 초기화하고 연동을 준비 */
naverLogin.init();
Kakao.init("@kakaoAppkey");
}
</script>

View File

@ -4,6 +4,9 @@
var em = new NP.Model.MenuPage();
var mainprivate = (menus.Where(w => w.refcode == "main.private").FirstOrDefault() ?? em);
var mainagree = (menus.Where(w => w.refcode == "main.agree").FirstOrDefault() ?? em);
var naverClientId = "fvaj0CdI04awGMEhaICy";
var kakaoAppkey = "7b09519e7bce67d548a2a594a48acf63";
}
<head>
<script type="text/javascript" src="/js/naveridlogin_js_sdk_2.0.0.js"></script>
@ -213,54 +216,93 @@ else
}
}
/*(1) 네이버 Javscript 설정 정보 및 초기화*/
var naverLogin = new naver.LoginWithNaverId(
{
clientId: "fvaj0CdI04awGMEhaICy", //개발자센터에 등록한 ClientID
callbackUrl: "https://www.ynicte.com/Account/Join",//개발자센터에 등록한 callback Url
isPopup: false, /* 팝업을 통한 연동처리 여부 */
callbackHandle: true
/* callback 페이지가 분리되었을 경우에 callback 페이지에서는 callback처리를 해줄수 있도록 설정합니다. */
}
);
/* (2) 네이버 로그인 정보를 초기화하기 위하여 init을 호출 */
naverLogin.init();
/* (3) Callback의 처리. 정상적으로 Callback 처리가 완료될 경우 main page로 redirect(또는 Popup close) */
window.addEventListener('load', function () {
naverLogin.getLoginStatus(function (status) {
if (status) {
/* (4) 필수적으로 받아야하는 프로필 정보가 있다면 callback처리 시점에 체크 */
var email = naverLogin.user.getEmail();
var name = naverLogin.user.getName();
var uniqId = naverLogin.user.getId();
var profileImage = naverLogin.user.getProfileImage();
var birthday = naverLogin.user.getBirthday();
var age = naverLogin.user.getAge();
if (email == undefined || email == null) {
alert("이메일은 필수정보입니다. 정보제공을 동의해주세요.");
/* (4-1) 사용자 정보 재동의를 위하여 다시 네이버로그인 동의페이지로 이동함 */
naverLogin.reprompt();
return;
}
if (name == undefined || name == null) {
alert("이름은 필수정보입니다. 정보제공을 동의해주세요.");
naverLogin.reprompt();
return;
if (@Request["jointype"] == "2") {
var naverLogin = new naver.LoginWithNaverId(
{
clientId: "@naverClientId",
callbackUrl: "https://www.ynicte.com/Account/Join?jointype=2",
isPopup: false,
callbackHandle: true
}
);
$("#username").val(name);
$("#email").val(email);
$("#snsid").val(uniqId);
$("#jointype").val(2); //0:일반회원가입,1:google,2:naver,3:kakao
$("#username").prop("readonly", "readonly");
$("#username").css("background-color", "#ddd");
$("#email").prop("readonly", "readonly");
$("#email").css("background-color", "#ddd");
} else {
console.log("callback 처리에 실패하였습니다.");
}
});
naverLogin.init();
naverLogin.getLoginStatus(function (status) {
if (status) {
var email = naverLogin.user.getEmail();
var name = naverLogin.user.getName();
var uniqId = naverLogin.user.getId();
var profileImage = naverLogin.user.getProfileImage();
var birthday = naverLogin.user.getBirthday();
var age = naverLogin.user.getAge();
if (email == undefined || email == null) {
alert("이메일은 필수정보입니다. 정보제공을 동의해주세요.");
naverLogin.reprompt();
return;
}
if (name == undefined || name == null) {
alert("이름은 필수정보입니다. 정보제공을 동의해주세요.");
naverLogin.reprompt();
return;
}
$("#username").val(name);
$("#email").val(email);
$("#snsid").val(uniqId);
$("#jointype").val(2); //0:일반회원가입,1:google,2:naver,3:kakao
$("#username").prop("readonly", "readonly");
$("#username").css("background-color", "#ddd");
$("#email").prop("readonly", "readonly");
$("#email").css("background-color", "#ddd");
} else {
console.log("callback 처리에 실패하였습니다.");
}
});
}
if (@Request["jointype"] == "3") {
$.when(
Kakao.init("@kakaoAppkey"),
kakaoDisplayToken()
).done(function () {
Kakao.API.request({
url: '/v2/user/me',
success: function (res) {
$("#username").val(res.properties.nickname);
$("#email").val(res.kakao_account.email);
$("#snsid").val(res.id);
$("#jointype").val(3); //0:일반회원가입,1:google,2:naver,3:kakao
$("#username").prop("readonly", "readonly");
$("#username").css("background-color", "#ddd");
$("#email").prop("readonly", "readonly");
$("#email").css("background-color", "#ddd");
},
fail: function (error) {
console.log(error);
}
});
});
}
});
function kakaoDisplayToken() {
const token = getKakaoCookie('authorize-access-token')
if (token) {
Kakao.Auth.setAccessToken(token)
Kakao.Auth.getStatusInfo(({ status }) => {
if (status === 'connected') {
document.getElementById('token-result').innerText = 'login success. token: ' + Kakao.Auth.getAccessToken()
} else {
Kakao.Auth.setAccessToken(null)
}
})
}
}
function getKakaoCookie(name) {
const value = "; " + document.cookie;
const parts = value.split("; " + name + "=");
if (parts.length === 2) return parts.pop().split(";").shift();
}
</script>
}

View File

@ -1,4 +1,8 @@
<head>
@{
var naverClientId = "fvaj0CdI04awGMEhaICy";
var kakaoAppkey = "7b09519e7bce67d548a2a594a48acf63";
}
<head>
<script type="text/javascript" src="/js/naveridlogin_js_sdk_2.0.0.js"></script>
<script type="text/javascript" src="/js/kakao.js"></script>
</head>
@ -15,6 +19,8 @@
</li>
<li><a href="#">구글 아이디로 회원가입</a></li>
</ul>
<a id="kakao-login-btn"></a>
</div>
</form>
@ -25,21 +31,16 @@
});
var naverLogin = new naver.LoginWithNaverId(
{
clientId: "fvaj0CdI04awGMEhaICy", //개발자센터에 등록한 ClientID
callbackUrl: "https://www.ynicte.com/Account/Join",//개발자센터에 등록한 callback Url //회원가입 페이지로 이동시킨다
isPopup: false, /* 팝업을 통한 연동처리 여부 */
loginButton: { color: "green", type: 3, height: 60 } /* 로그인 버튼의 타입을 지정 */
clientId: "@naverClientId",
callbackUrl: "https://www.ynicte.com/Account/Join?jointype=2",
isPopup: false,
loginButton: { color: "green", type: 3, height: 60 }
}
);
function loginWithKakao() {
Kakao.Auth.login({
success: function (authObj) {
alert(JSON.stringify(authObj))
},
fail: function (err) {
alert(JSON.stringify(err))
},
Kakao.Auth.authorize({
redirectUri: 'https://www.ynicte.com/Account/Join?jointype=3'
})
}
@ -48,13 +49,7 @@
}
function snsInit() {
/* 네이버 설정정보를 초기화하고 연동을 준비 */
naverLogin.init();
// 카카오 SDK를 초기화 합니다. 사용할 앱의 JavaScript 키를 설정해 주세요.
Kakao.init('f30a121bf140bf3d3dbf72012b7d713c');
// SDK 초기화 여부를 판단합니다.
console.log(Kakao.isInitialized());
Kakao.init("@kakaoAppkey");
}
</script>

View File

@ -0,0 +1,72 @@
@{
Layout = null;
var kakaoAppkey = "7b09519e7bce67d548a2a594a48acf63";
}
<head>
@Html.Partial("./Partial/JS")
<script type="text/javascript" src="/js/kakao.js"></script>
</head>
<script>
function kakaoDisplayToken() {
const token = getKakaoCookie('authorize-access-token')
if (token) {
Kakao.Auth.setAccessToken(token)
Kakao.Auth.getStatusInfo(({ status }) => {
if (status === 'connected') {
document.getElementById('token-result').innerText = 'login success. token: ' + Kakao.Auth.getAccessToken()
} else {
Kakao.Auth.setAccessToken(null)
}
})
}
}
function getKakaoCookie(name) {
const value = "; " + document.cookie;
const parts = value.split("; " + name + "=");
if (parts.length === 2) return parts.pop().split(";").shift();
}
var snsid;
window.addEventListener('load', function () {
$.when(
Kakao.init("@kakaoAppkey"),
kakaoDisplayToken()
).done(function () {
Kakao.API.request({
url: '/v2/user/me',
success: function (res) {
snsid = res.id;
//0:일반회원가입,1:google,2:naver,3:kakao
capp("/focommon/CheckExistSnsId", { snsid: snsid, jointype: 3 }, "snslogin");
},
fail: function (error) {
console.log(error);
}
});
});
});
function snslogin() {
if (capResult.code > 0) {
capp("/focommon/SnsLogin", { uid: snsid, isSns: true }, "goHome()");
}
else {
if (confirm("SNS 회원정보가 존재하지 않습니다.\r\n회원가입 페이지로 이동하시겠습니까?")) {
goJoin();
}
else {
goIndex();
}
}
}
function goJoin() {
location.href = "https://www.ynicte.com/Account/JoinTSel";
}
function goHome() {
location.href = "https://www.ynicte.com";
}
function goIndex() {
location.href = "https://www.ynicte.com/Account/Index";
}
</script>

View File

@ -1,18 +1,18 @@
@{
Layout = null;
var naverClientId = "fvaj0CdI04awGMEhaICy";
}
<head>
<!-- SNS -->
@Html.Partial("./Partial/JS")
<script type="text/javascript" src="/js/naveridlogin_js_sdk_2.0.0.js"></script>
<script type="text/javascript" src="/js/kakao.js"></script>
</head>
<script>
/*(1) 네이버 Javscript 설정 정보 및 초기화*/
var snsid;
var naverLogin = new naver.LoginWithNaverId(
{
clientId: "fvaj0CdI04awGMEhaICy", //개발자센터에 등록한 ClientID
clientId: "@naverClientId", //개발자센터에 등록한 ClientID
callbackUrl: "https://www.ynicte.com/Account/NaverCallback",//개발자센터에 등록한 callback Url
isPopup: false, /* 팝업을 통한 연동처리 여부 */
callbackHandle: true