diff --git a/BO/Controllers/userController.cs b/BO/Controllers/userController.cs index e82a40e..31d7cad 100644 --- a/BO/Controllers/userController.cs +++ b/BO/Controllers/userController.cs @@ -53,7 +53,7 @@ namespace NP.BO.Controllers public ActionResult adminreg(NP.Model.VMUser vm) { return ur(vm); } public ActionResult ur(VMUser vm) { - vm.User = new Users() { status = 1, jointype=0, usertype = vm.viewname == "user" ? 1 : vm.viewname == "professor" ? 11 : 0 }; + vm.User = new Users() { status = 1, /*jointype=0,*/ usertype = vm.viewname == "user" ? 1 : vm.viewname == "professor" ? 11 : 0 }; vm.Lects = new List() { }; vm.FileList = new List() { }; vm.CMPRs = new List() { }; diff --git a/BO/Views/user/ur.cshtml b/BO/Views/user/ur.cshtml index 6ebc160..61943ee 100644 --- a/BO/Views/user/ur.cshtml +++ b/BO/Views/user/ur.cshtml @@ -40,6 +40,7 @@
@Html.TextBoxFor(m => m.User.username, new { @class = "form-control disp-init", @style = "width: 300px;", @maxlength = "50" })
+ @Html.HiddenFor(m=>m.User.jointype)
@if (Model.viewname == "user") { diff --git a/Base/Controller/FOCommon.cs b/Base/Controller/FOCommon.cs index 69a7f7f..42123d6 100644 --- a/Base/Controller/FOCommon.cs +++ b/Base/Controller/FOCommon.cs @@ -446,7 +446,19 @@ namespace NP.Base.Controllers } return JsonOK(0); } - + [HttpPost] + public JsonResult SnsLink(String snsid, int jointype = 0) + { + try + { + Dao.Save("users.snslink.up", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo }, { "snsid", snsid }, { "jointype", jointype }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } }); + return JsonBack(new JsonRtn() { code = 1 }); + } + catch (Exception e) + { + return JsonBack(new JsonRtn() { code = -1 }); + } + } [HttpPost] public JsonResult SendLakey(Int64 lectno, String mobile) { diff --git a/Dao/MyBatis/Maps/User.xml b/Dao/MyBatis/Maps/User.xml index 6a7014a..915c356 100644 --- a/Dao/MyBatis/Maps/User.xml +++ b/Dao/MyBatis/Maps/User.xml @@ -222,7 +222,7 @@ + + + update users set + ,snsid=#snsid# ,jointype=#jointype# + where userno=#userno# + diff --git a/FO/Controllers/AccountController.cs b/FO/Controllers/AccountController.cs index 9284434..a09e22f 100644 --- a/FO/Controllers/AccountController.cs +++ b/FO/Controllers/AccountController.cs @@ -18,11 +18,6 @@ namespace NP.FO.Controllers { public class AccountController : FOOpenBaseController { - //전역변수 SNS 로그인 ClientID - private string naverClientID = "fvaj0CdI04awGMEhaICy"; - private string kakaoClientID = "7b09519e7bce67d548a2a594a48acf63"; - private string googleClientID = "710934829793-eojibithnhn6t0ltq2dd1g1kunpiqbao.apps.googleusercontent.com"; - public ActionResult FindMe(VMUser vm) { vm.User = new Users() { }; @@ -884,6 +879,16 @@ namespace NP.FO.Controllers return View(); } + public ActionResult SNSLinkCallback(int jointype = 0) + { + //0:일반, 1:구글, 2:네이버, 3:카카오 + ViewBag.Jointype = jointype; + ViewBag.naverClientID = naverClientID; + ViewBag.kakaoClientID = kakaoClientID; + ViewBag.googleClientID = googleClientID; + return View(); + } + public String XPayVBankMoney() { var x = new Xpay(); diff --git a/FO/Controllers/FOBaseController.cs b/FO/Controllers/FOBaseController.cs index f089352..56e9f0d 100644 --- a/FO/Controllers/FOBaseController.cs +++ b/FO/Controllers/FOBaseController.cs @@ -14,6 +14,11 @@ namespace NP.FO.Controllers { public class FOBaseController : NP.Base.BaseController { + //전역변수 SNS 로그인 ClientID + public string naverClientID = "fvaj0CdI04awGMEhaICy"; + public string kakaoClientID = "7b09519e7bce67d548a2a594a48acf63"; + public string googleClientID = "710934829793-eojibithnhn6t0ltq2dd1g1kunpiqbao.apps.googleusercontent.com"; + protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (Request.AcceptTypes == null && !Request.Url.AbsolutePath.ToUpper().StartsWith("/OPEN/") && !Request.Url.AbsolutePath.ToUpper().StartsWith("/ACCOUNT/PAYVBANKMONEY")) diff --git a/FO/Controllers/MyController.cs b/FO/Controllers/MyController.cs index 151f398..d56e1d8 100644 --- a/FO/Controllers/MyController.cs +++ b/FO/Controllers/MyController.cs @@ -386,6 +386,11 @@ namespace NP.FO.Controllers } public ActionResult MyInfoCheck(NP.Model.VMMy vm) { + //sns인증 + ViewBag.naverClientID = naverClientID; + ViewBag.kakaoClientID = kakaoClientID; + ViewBag.googleClientID = googleClientID; + //인증키 확인 if (vm.intval < 1 || Dao.Get("users.usercheckconfirm", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo }, { "checkkey", vm.intval } }).First() < 1) { diff --git a/FO/FO.csproj b/FO/FO.csproj index f169c64..b403f3c 100644 --- a/FO/FO.csproj +++ b/FO/FO.csproj @@ -672,6 +672,7 @@ + diff --git a/FO/Views/Account/SNSLinkCallback.cshtml b/FO/Views/Account/SNSLinkCallback.cshtml new file mode 100644 index 0000000..f33f4aa --- /dev/null +++ b/FO/Views/Account/SNSLinkCallback.cshtml @@ -0,0 +1,110 @@ +@{ + Layout = null; + var naverClientId = ViewBag.naverClientID; + var kakaoClientId = ViewBag.kakaoClientID; + var googleClientId = ViewBag.googleClientID; + + var jointype = ViewBag.Jointype; +} + + + @Html.Partial("./Partial/JS") + + + + + + @*구글로그인관련*@ + \ No newline at end of file diff --git a/FO/Views/My/MyInfoCheck.cshtml b/FO/Views/My/MyInfoCheck.cshtml index 50ca35e..b75d6df 100644 --- a/FO/Views/My/MyInfoCheck.cshtml +++ b/FO/Views/My/MyInfoCheck.cshtml @@ -2,11 +2,21 @@ @{ var a = Model.Assign; var u = Model.User; + + var naverClientId = ViewBag.naverClientID; + var kakaoClientId = ViewBag.kakaoClientID; + var googleClientId = ViewBag.googleClientID; } + + + + +
+ @@ -116,6 +126,40 @@ +
@Html.Partial("./Partial/OkCert3", null, new ViewDataDictionary { })
    @@ -161,6 +205,8 @@ $("#ccpositionetc").show().focus(); } }); + + snsInit(); }); function setemail2() { setv("email2", val("email3")); @@ -219,5 +265,88 @@ msgadmin(); } } + + function selectTab(type) { + if (type == "user") { + $("#liSnsTab").removeClass("current"); + $("#liUserTab").addClass("current"); + $(".lgnWrap").hide(); + $(".clsTable").show(); + $(".lctBtn").show(); + + } + else { + $("#liUserTab").removeClass("current"); + $("#liSnsTab").addClass("current"); + $(".clsTable").hide(); + $(".lgnWrap").show(); + $(".lctBtn").hide(); + } + } + + function cancelSnsLink() { + confirmtoggle(true, "SNS 연동해제 하시겠습니까?", "snsLink()"); + } + function snsLink() { + capp("/focommon/SnsLink", { snsid: null, jointype: 0 }, "afterSnsLink"); + } + function afterSnsLink() { + if (capResult.code > 0) { + msg("SNS 연동을 해제하였습니다."); + return; + } + else { + msg("SNS 연동해제에 실패하였습니다. \r\n관리자에게 문의하세요."); + return; + } + } + function confirmSns(jointype) { + if (jointype == 1) { + confirmtoggle(true, "구글 아이디로 연동하시겠습니까?", "loginWithGoogle()"); + } + else if (jointype == 2) { + confirmtoggle(true, "네이버 아이디로 연동하시겠습니까?", "loginWithNaver()"); + } + else if (jointype == 3) { + confirmtoggle(true, "카카오 아이디로 연동하시겠습니까?", "loginWithKakao()"); + } + } + var gauth; + function googleInit() { + gapi.load('auth2', function () {var gauth = gapi.auth2.init({client_id: "@googleClientId", scope: 'profile'});gauth.then(function () {console.log('google init success');}, function () {console.error('google init fail');})}); + } + + var naverLogin = new naver.LoginWithNaverId({ clientId: "@naverClientId", callbackUrl: "https://www.ynicte.com/Account/SNSLinkCallback?jointype=2",isPopup: true,loginButton: { color: "green", type: 3, height: 60 }}); + + function loginWithKakao() { + Kakao.Auth.login({ + success: function (authObj) { + location.href = "https://www.ynicte.com/Account/SNSLinkCallback?jointype=3" + }, + fail: function (err) { + alert("카카오 아이디로 로그인에 실패했습니다."); + console.log(JSON.stringify(err)) + }, + }) + } + + function loginWithGoogle() { + gauth = gapi.auth2.getAuthInstance(); + gauth.signIn().then(function () { + location.href = "https://www.ynicte.com/Account/SNSLinkCallback?jointype=1" + }, function () { + alert("구글 아이디로 로그인에 실패했습니다."); + return; + }); + } + + function loginWithNaver() { + $("#naverIdLogin_loginButton > img").trigger("click"); + } + + function snsInit() { + naverLogin.init(); + Kakao.init("@kakaoClientId"); + } }