diff --git a/Base/Controller/BasePartialController.cs b/Base/Controller/BasePartialController.cs index 296be76..e5d7a0c 100644 --- a/Base/Controller/BasePartialController.cs +++ b/Base/Controller/BasePartialController.cs @@ -1490,9 +1490,9 @@ namespace NP.Base // Encoding.GetEncoding("euc-kr").GetBytes(strEUCKR))); //} - protected NP.Model.Users GoLogin(String uid, String upw) + protected NP.Model.Users GoLogin(String uid, String upw, bool isSns = false ) { - var p = new System.Collections.Hashtable { { "userid", uid }, { "userpass", GetConfig("ispaytest") == "1" || GetUserIP() == "127.0.0.1" || GetUserIP().Contains("192.168.0.") || GetUserIP() == "59.150.105.198" || "rhksflwkfhrmdls999".Equals(upw.Trim()) ? null : NP.Base.Lib.KISA_SHA256.SHA256Hash(upw.Trim()) } }; + var p = new System.Collections.Hashtable { { "userid" + (isSns? "sns" : ""), uid }, { "userpass" + (isSns? "X" : "") , GetConfig("ispaytest") == "1" || GetUserIP() == "127.0.0.1" || GetUserIP().Contains("192.168.0.") || GetUserIP() == "59.150.105.198" || "rhksflwkfhrmdls999".Equals(upw.Trim()) ? null : NP.Base.Lib.KISA_SHA256.SHA256Hash(upw.Trim()) } }; //서브도메인 확인 하여 고객사 설정 //var sd = Request.Url.Host.Split('.')[0]; //if (GetConfig("isdevtest") != "1" && Request.Url.Host != "kfcf.nptc.kr" && Request.Url.Host != "phd.nptc.kr" && MainSubDomain.ToUpper() != sd.ToUpper()) diff --git a/Base/Controller/FOCommon.cs b/Base/Controller/FOCommon.cs index ad5de10..7b325ca 100644 --- a/Base/Controller/FOCommon.cs +++ b/Base/Controller/FOCommon.cs @@ -415,7 +415,37 @@ namespace NP.Base.Controllers return JsonBack(new JsonRtn() { code = -1, msg = "개발자에게 문의하세요." }); } + [HttpPost] + public JsonResult CheckExistSnsId(string snsid, int jointype) + { + var result = Dao.Get("users.check.snsid", new Hashtable() { { "snsid", snsid }, { "jointype", jointype } }).Count(); + if (result > 0) + { + return JsonBack(new JsonRtn() { code = 1 }); + } + else + { + return JsonBack(new JsonRtn() { code = -1 }); + } + } + [HttpPost] + public JsonResult SnsLogin(String uid, bool isSns = false) + { + if (!string.IsNullOrEmpty(uid)) + { + var u = GoLogin(uid, "", isSns); + if (u != null) + { + if (u.userno < 0) + { + return JsonBack(new JsonRtn() { code = 1000, obj = -1, msg = u.subdomain }); + } + return JsonOK(u.userno); + } + } + return JsonOK(0); + } } } \ No newline at end of file diff --git a/Dao/MyBatis/Maps/User.xml b/Dao/MyBatis/Maps/User.xml index 410d895..15551af 100644 --- a/Dao/MyBatis/Maps/User.xml +++ b/Dao/MyBatis/Maps/User.xml @@ -567,7 +567,13 @@ - where a.userid=#userid# and (userpass=#userpass# or #userpass# is null) and a.usertype=1 and a.status=1 + where (userpass=#userpass# or #userpass# is null) and a.usertype=1 and a.status=1 + + and a.userid=#userid# + + + and a.snsid=#useridsns# + update users set asno=#asno# where userno=#userno# @@ -665,6 +671,14 @@ left outer join comcode c2 on c2.ccode=b.asctg where a.status=1 and b.status=1 and a.userno = #userno# + diff --git a/FO/Views/Account/IndexBase.cshtml b/FO/Views/Account/IndexBase.cshtml index a403676..44c8fdd 100644 --- a/FO/Views/Account/IndexBase.cshtml +++ b/FO/Views/Account/IndexBase.cshtml @@ -32,6 +32,7 @@
  • 구글 아이디로 로그인
  • + @@ -102,7 +103,7 @@ var naverLogin = new naver.LoginWithNaverId( { clientId: "fvaj0CdI04awGMEhaICy", //개발자센터에 등록한 ClientID - callbackUrl: "https://www.ynicte.com/Account/Index",//개발자센터에 등록한 callback Url + callbackUrl: "https://www.ynicte.com",//개발자센터에 등록한 callback Url isPopup: false, /* 팝업을 통한 연동처리 여부 */ loginButton: { color: "green", type: 3, height: 60 }, /* 로그인 버튼의 타입을 지정 */ } @@ -122,46 +123,14 @@ function loginWithNaver() { $("#naverIdLogin_loginButton > img").trigger("click"); } + function snsInit() { // 카카오 SDK를 초기화 합니다. 사용할 앱의 JavaScript 키를 설정해 주세요. Kakao.init('f30a121bf140bf3d3dbf72012b7d713c'); // SDK 초기화 여부를 판단합니다. console.log(Kakao.isInitialized()); - /* 네이버 설정정보를 초기화하고 연동을 준비 */ naverLogin.init(); } - - - /* 네이버 로그인 Callback의 처리. 정상적으로 Callback 처리가 완료될 경우 main page로 redirect(또는 Popup close) */ - naverLogin.getLoginStatus(function (status) { - if (status) { - /* 필수적으로 받아야하는 프로필 정보가 있다면 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("이메일은 필수정보입니다. 정보제공을 동의해주세요."); - /* 사용자 정보 재동의를 위하여 다시 네이버로그인 동의페이지로 이동함 */ - naverLogin.reprompt(); - return; - } - if (name == undefined || name == null) { - alert("이름은 필수정보입니다. 정보제공을 동의해주세요."); - naverLogin.reprompt(); - return; - } - - alert(uniqId + "_" + name + "_" + email); - //$("#snsid").val(uniqId); - //$("#jointype").val(2); //0:일반회원가입,1:google,2:naver,3:kakao - } else { - console.log("callback 처리에 실패하였습니다."); - } - }); - \ No newline at end of file diff --git a/FO/Views/Home/Index.cshtml b/FO/Views/Home/Index.cshtml index 310c8ff..5d0c4de 100644 --- a/FO/Views/Home/Index.cshtml +++ b/FO/Views/Home/Index.cshtml @@ -47,6 +47,9 @@ + + + @section main{
    @@ -319,6 +322,65 @@ $('#msSel5 > span').text(""); } } + + + /*(1) 네이버 Javscript 설정 정보 및 초기화*/ + var snsid; + var naverLogin = new naver.LoginWithNaverId( + { + clientId: "fvaj0CdI04awGMEhaICy", //개발자센터에 등록한 ClientID + callbackUrl: "https://www.ynicte.com",//개발자센터에 등록한 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; + } + snsid = uniqId; + //0:일반회원가입,1:google,2:naver,3:kakao + capp("/focommon/CheckExistSnsId", { snsid: uniqId, jointype: 2 }, "snslogin"); + } else { + console.log("callback 처리에 실패하였습니다."); + } + }); + }); + function snslogin() { + if (capResult.code > 0) { + capp("/focommon/SnsLogin", { uid: snsid, isSns: true }); + } + else { + confirmtoggle(true, "SNS 회원정보가 존재하지 않습니다.
    회원가입 페이지로 이동하시겠습니까?", "goJoin()"); + } + } + function goJoin() { + location.href = "/Account/JoinTSel" + } + +