This commit is contained in:
parent
7a0547d7ff
commit
44f482dd80
|
|
@ -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<String>(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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -671,6 +671,7 @@
|
|||
<Content Include="Views\Account\NaverCallback.cshtml" />
|
||||
<Content Include="Views\Account\KakaoCallback.cshtml" />
|
||||
<Content Include="Views\Account\NaverCallbackJoin.cshtml" />
|
||||
<Content Include="Views\Account\GoogleCallback.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
@{
|
||||
Layout = null;
|
||||
var naverClientId = ViewBag.naverClientID;
|
||||
var kakaoClientId = ViewBag.kakaoClientID;
|
||||
var googleClientId = ViewBag.googleClientID;
|
||||
}
|
||||
<head>
|
||||
@Html.Partial("./Partial/JS")
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
<meta name="google-signin-client_id" content="@googleClientId">
|
||||
</head>
|
||||
<div class="g-signin2" data-onsuccess="onGoogleLogIn" style="display:none"></div> @*구글로그인관련*@
|
||||
<script>
|
||||
var snsid;
|
||||
function onGoogleLogIn(googleUser) {
|
||||
var profile = googleUser.getBasicProfile();
|
||||
snsid = profile.getId();
|
||||
capp("/focommon/CheckExistSnsId", { snsid: snsid, jointype: 1 }, "snslogin");
|
||||
}
|
||||
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>
|
||||
|
|
@ -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;
|
||||
}
|
||||
<head>
|
||||
<script type="text/javascript" src="/js/naveridlogin_js_sdk_2.0.0.js"></script>
|
||||
<script type="text/javascript" src="/js/kakao.js"></script>
|
||||
<script src="https://apis.google.com/js/platform.js?onload=googleInit" async defer></script>
|
||||
</head>
|
||||
<form id="mform" action="" method="post">
|
||||
<div class="lgnWrap">
|
||||
|
|
@ -34,12 +36,15 @@
|
|||
<li>
|
||||
<a href="javascript:loginWithKakao()">카카오 아이디로 로그인</a>
|
||||
</li>
|
||||
<li><a href="#">구글 아이디로 로그인</a></li>
|
||||
<li>
|
||||
<a href="javascript:loginWithGoogle()">구글 아이디로 로그인</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
if (opener != null && opener._ismain == 1) {
|
||||
opener.location.href = "/Account/Index";
|
||||
|
|
@ -76,9 +81,23 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
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');
|
||||
})
|
||||
});
|
||||
}
|
||||
function login() {
|
||||
if (val("uid") != "" && val("upw") != "") {
|
||||
capp("/focommon/login", { uid: val("uid"), upw: val("upw"), issaveid: $("#issaveid").prop("checked") }, "cblogin");
|
||||
|
|
@ -124,12 +143,22 @@
|
|||
})
|
||||
}
|
||||
|
||||
function loginWithGoogle() {
|
||||
gauth = gapi.auth2.getAuthInstance();
|
||||
gauth.signIn().then(function () {
|
||||
location.href = "https://www.ynicte.com/Account/GoogleCallback"
|
||||
}, function () {
|
||||
alert("구글 아이디로 로그인에 실패했습니다.");
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
function loginWithNaver() {
|
||||
$("#naverIdLogin_loginButton > img").trigger("click");
|
||||
}
|
||||
|
||||
function snsInit() {
|
||||
naverLogin.init();
|
||||
Kakao.init("@kakaoAppkey");
|
||||
Kakao.init("@kakaoClientId");
|
||||
}
|
||||
</script>
|
||||
|
|
@ -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;
|
||||
}
|
||||
<head>
|
||||
<script type="text/javascript" src="/js/naveridlogin_js_sdk_2.0.0.js"></script>
|
||||
<script type="text/javascript" src="/js/kakao.js"></script>
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
<meta name="google-signin-client_id" content="@googleClientId">
|
||||
</head>
|
||||
<div class="g-signin2" data-onsuccess="onGoogleLogIn" style="display:none"></div> @*구글로그인관련*@
|
||||
@if (ViewBag.JoinOK)
|
||||
{
|
||||
<ul class="jnStep">
|
||||
|
|
@ -126,7 +130,6 @@ else
|
|||
@section scriptsHeader{
|
||||
@Html.Partial("./Partial/ScriptPost")
|
||||
}
|
||||
@section scripts{
|
||||
<script>
|
||||
function bindassign(v) {
|
||||
$("#asno").val(v.split(':')[0]);
|
||||
|
|
@ -136,6 +139,7 @@ else
|
|||
if ('@(ViewBag.JoinOK?1:0)' == '1') {
|
||||
$("#pageTitle h3").text("회원가입 완료");
|
||||
}
|
||||
snsLogin();
|
||||
});
|
||||
function save() {
|
||||
setv("userid", val("userid").replace(/ /, '').replace(/ /, ''));
|
||||
|
|
@ -216,7 +220,21 @@ else
|
|||
}
|
||||
}
|
||||
|
||||
window.addEventListener('load', function () {
|
||||
function onGoogleLogIn(googleUser) {
|
||||
if (@Request["jointype"] == "1") {
|
||||
var profile = googleUser.getBasicProfile();
|
||||
$("#username").val(profile.getName());
|
||||
$("#email").val(profile.getEmail());
|
||||
$("#snsid").val(profile.getId());
|
||||
$("#jointype").val(1); //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");
|
||||
}
|
||||
}
|
||||
|
||||
function snsLogin() {
|
||||
if (@Request["jointype"] == "2") {
|
||||
var naverLogin = new naver.LoginWithNaverId(
|
||||
{
|
||||
|
|
@ -226,7 +244,6 @@ else
|
|||
callbackHandle: true
|
||||
}
|
||||
);
|
||||
|
||||
naverLogin.init();
|
||||
naverLogin.getLoginStatus(function (status) {
|
||||
if (status) {
|
||||
|
|
@ -256,13 +273,15 @@ else
|
|||
$("#email").prop("readonly", "readonly");
|
||||
$("#email").css("background-color", "#ddd");
|
||||
} else {
|
||||
console.log("callback 처리에 실패하였습니다.");
|
||||
alert("callback 처리에 실패하였습니다. 관리자에게 문의하세요. error status[" + status + "]");
|
||||
history.back(-1);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (@Request["jointype"] == "3") {
|
||||
$.when(
|
||||
Kakao.init("@kakaoAppkey"),
|
||||
Kakao.init("@kakaoClientId"),
|
||||
).done(function () {
|
||||
Kakao.API.request({
|
||||
url: '/v2/user/me',
|
||||
|
|
@ -281,8 +300,6 @@ else
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
@{
|
||||
var naverClientId = "fvaj0CdI04awGMEhaICy";
|
||||
var kakaoAppkey = "7b09519e7bce67d548a2a594a48acf63";
|
||||
var naverClientId = ViewBag.naverClientID;
|
||||
var kakaoClientId = ViewBag.kakaoClientID;
|
||||
var googleClientId = ViewBag.googleClientID;
|
||||
}
|
||||
<head>
|
||||
<script type="text/javascript" src="/js/naveridlogin_js_sdk_2.0.0.js"></script>
|
||||
<script type="text/javascript" src="/js/kakao.js"></script>
|
||||
<script src="https://apis.google.com/js/platform.js?onload=googleInit" async defer></script>
|
||||
</head>
|
||||
<form id="mform" method="post">
|
||||
<div class="jnSns">
|
||||
|
|
@ -17,9 +19,10 @@
|
|||
<li>
|
||||
<a href="javascript:loginWithKakao()">카카오 아이디로 회원가입</a>
|
||||
</li>
|
||||
<li><a href="#">구글 아이디로 회원가입</a></li>
|
||||
<li>
|
||||
<a href="javascript:loginWithGoogle()">구글 아이디로 회원가입</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="kakao-login-btn"></a>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -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",
|
||||
|
|
@ -41,21 +61,29 @@
|
|||
function loginWithKakao() {
|
||||
Kakao.Auth.login({
|
||||
success: function (authObj) {
|
||||
location.href = "https://www.ynicte.com/Account/Join?jointype=3"
|
||||
location.href = "https://www.ynicte.com/Account/Join?jointype=3";
|
||||
},
|
||||
fail: function (err) {
|
||||
alert("카카오 아이디로 회원가입에 실패했습니다.");
|
||||
console.log(JSON.stringify(err))
|
||||
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");
|
||||
}
|
||||
</script>
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
@{
|
||||
Layout = null;
|
||||
var kakaoAppkey = "7b09519e7bce67d548a2a594a48acf63";
|
||||
var naverClientId = ViewBag.naverClientID;
|
||||
var kakaoClientId = ViewBag.kakaoClientID;
|
||||
var googleClientId = ViewBag.googleClientID;
|
||||
}
|
||||
<head>
|
||||
@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',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
@{
|
||||
Layout = null;
|
||||
var naverClientId = "fvaj0CdI04awGMEhaICy";
|
||||
var naverClientId = ViewBag.naverClientID;
|
||||
var kakaoClientId = ViewBag.kakaoClientID;
|
||||
var googleClientId = ViewBag.googleClientID;
|
||||
}
|
||||
<head>
|
||||
<!-- SNS -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue