diff --git a/FO/Controllers/AccountController.cs b/FO/Controllers/AccountController.cs index dfa66f7..9284434 100644 --- a/FO/Controllers/AccountController.cs +++ b/FO/Controllers/AccountController.cs @@ -18,6 +18,11 @@ 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() { }; @@ -34,6 +39,10 @@ namespace NP.FO.Controllers return View(vm); } public ActionResult Index(VMUser vm){ + ViewBag.naverClientID = naverClientID; + ViewBag.kakaoClientID = kakaoClientID; + ViewBag.googleClientID = googleClientID; + if (Request.IsAjaxRequest()){ return JsonError(Base.ENUM.JSONCode.Error, "403:" + Request.Url.AbsolutePath, "0112"); } @@ -81,6 +90,9 @@ namespace NP.FO.Controllers { ViewBag.JoinOK = true; } + ViewBag.naverClientID = naverClientID; + ViewBag.kakaoClientID = kakaoClientID; + ViewBag.googleClientID = googleClientID; return View(vm); //} } @@ -447,6 +459,9 @@ namespace NP.FO.Controllers public ActionResult JoinTSel() { + ViewBag.naverClientID = naverClientID; + ViewBag.kakaoClientID = kakaoClientID; + ViewBag.googleClientID = googleClientID; return View(); } @@ -842,14 +857,30 @@ namespace NP.FO.Controllers public ActionResult NaverCallback() { + ViewBag.naverClientID = naverClientID; + ViewBag.kakaoClientID = kakaoClientID; + ViewBag.googleClientID = googleClientID; return View(); } public ActionResult NaverCallbackJoin() { + ViewBag.naverClientID = naverClientID; + ViewBag.kakaoClientID = kakaoClientID; + ViewBag.googleClientID = googleClientID; return View(); } public ActionResult KakaoCallback() { + ViewBag.naverClientID = naverClientID; + ViewBag.kakaoClientID = kakaoClientID; + ViewBag.googleClientID = googleClientID; + return View(); + } + public ActionResult GoogleCallback() + { + ViewBag.naverClientID = naverClientID; + ViewBag.kakaoClientID = kakaoClientID; + ViewBag.googleClientID = googleClientID; return View(); } diff --git a/FO/FO.csproj b/FO/FO.csproj index 73c9fb3..7b34c1c 100644 --- a/FO/FO.csproj +++ b/FO/FO.csproj @@ -671,6 +671,7 @@ + diff --git a/FO/Views/Account/GoogleCallback.cshtml b/FO/Views/Account/GoogleCallback.cshtml new file mode 100644 index 0000000..c3e518e --- /dev/null +++ b/FO/Views/Account/GoogleCallback.cshtml @@ -0,0 +1,44 @@ +@{ + Layout = null; + var naverClientId = ViewBag.naverClientID; + var kakaoClientId = ViewBag.kakaoClientID; + var googleClientId = ViewBag.googleClientID; +} + + @Html.Partial("./Partial/JS") + + + + @*구글로그인관련*@ + \ No newline at end of file diff --git a/FO/Views/Account/IndexBase.cshtml b/FO/Views/Account/IndexBase.cshtml index 9daa10e..eccf63e 100644 --- a/FO/Views/Account/IndexBase.cshtml +++ b/FO/Views/Account/IndexBase.cshtml @@ -1,11 +1,13 @@ @model NP.Model.VMUser @{ - var naverClientId = "fvaj0CdI04awGMEhaICy"; - var kakaoAppkey = "7b09519e7bce67d548a2a594a48acf63"; + var naverClientId = ViewBag.naverClientID; + var kakaoClientId = ViewBag.kakaoClientID; + var googleClientId = ViewBag.googleClientID; } +
\ No newline at end of file diff --git a/FO/Views/Account/Join.cshtml b/FO/Views/Account/Join.cshtml index 1fd657e..d06a249 100644 --- a/FO/Views/Account/Join.cshtml +++ b/FO/Views/Account/Join.cshtml @@ -5,13 +5,17 @@ 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"; + var naverClientId = ViewBag.naverClientID; + var kakaoClientId = ViewBag.kakaoClientID; + var googleClientId = ViewBag.googleClientID; } + + + @*구글로그인관련*@ @if (ViewBag.JoinOK) {
    @@ -72,7 +76,7 @@ else
    • -
    • -
    • +
    @*인증완료상태여도 재인증 가능*@ @@ -126,163 +130,176 @@ else @section scriptsHeader{ @Html.Partial("./Partial/ScriptPost") } -@section scripts{ - -} \ No newline at end of file + }); + } + } + diff --git a/FO/Views/Account/JoinTSel.cshtml b/FO/Views/Account/JoinTSel.cshtml index a27b10c..b775154 100644 --- a/FO/Views/Account/JoinTSel.cshtml +++ b/FO/Views/Account/JoinTSel.cshtml @@ -1,10 +1,12 @@ @{ - var naverClientId = "fvaj0CdI04awGMEhaICy"; - var kakaoAppkey = "7b09519e7bce67d548a2a594a48acf63"; + var naverClientId = ViewBag.naverClientID; + var kakaoClientId = ViewBag.kakaoClientID; + var googleClientId = ViewBag.googleClientID; } +
- @@ -29,6 +32,23 @@ $(document).ready(function () { snsInit(); }); + 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", @@ -39,23 +59,31 @@ ); function loginWithKakao() { - Kakao.Auth.login({ - success: function (authObj) { - location.href = "https://www.ynicte.com/Account/Join?jointype=3" - }, - fail: function (err) { - alert("카카오 아이디로 회원가입에 실패했습니다."); - console.log(JSON.stringify(err)) - }, + Kakao.Auth.login({ + success: function (authObj) { + location.href = "https://www.ynicte.com/Account/Join?jointype=3"; + }, + fail: function (err) { + alert("카카오 아이디로 회원가입에 실패했습니다."); + console.log(JSON.stringify(err)); + }, }) } - function loginWithNaver() { $("#naverIdLogin_loginButton > img").trigger("click"); } + function loginWithGoogle() { + gauth = gapi.auth2.getAuthInstance(); + gauth.signIn().then(function () { + //var profile = gauth.currentUser.get().getBasicProfile(); + //location.href = "https://www.ynicte.com/Account/Join?jointype=1&gid=" + encodeURI(profile.getId()) + "&gnm=" + encodeURI(profile.getName()) + "&gml=" + encodeURI(profile.getEmail()); + location.href = "https://www.ynicte.com/Account/Join?jointype=1"; + }); + } + function snsInit() { naverLogin.init(); - Kakao.init("@kakaoAppkey"); + Kakao.init("@kakaoClientId"); } \ No newline at end of file diff --git a/FO/Views/Account/KakaoCallback.cshtml b/FO/Views/Account/KakaoCallback.cshtml index a3dc85e..42cd412 100644 --- a/FO/Views/Account/KakaoCallback.cshtml +++ b/FO/Views/Account/KakaoCallback.cshtml @@ -1,6 +1,8 @@ @{ Layout = null; - var kakaoAppkey = "7b09519e7bce67d548a2a594a48acf63"; + var naverClientId = ViewBag.naverClientID; + var kakaoClientId = ViewBag.kakaoClientID; + var googleClientId = ViewBag.googleClientID; } @Html.Partial("./Partial/JS") @@ -10,7 +12,7 @@ var snsid; window.addEventListener('load', function () { $.when( - Kakao.init("@kakaoAppkey") + Kakao.init("@kakaoClientId") ).done(function () { Kakao.API.request({ url: '/v2/user/me', diff --git a/FO/Views/Account/NaverCallback.cshtml b/FO/Views/Account/NaverCallback.cshtml index 1faac0d..7f5c50c 100644 --- a/FO/Views/Account/NaverCallback.cshtml +++ b/FO/Views/Account/NaverCallback.cshtml @@ -1,6 +1,8 @@ @{ Layout = null; - var naverClientId = "fvaj0CdI04awGMEhaICy"; + var naverClientId = ViewBag.naverClientID; + var kakaoClientId = ViewBag.kakaoClientID; + var googleClientId = ViewBag.googleClientID; }