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");
|
||||
|
|
@ -113,23 +132,33 @@
|
|||
);
|
||||
|
||||
function loginWithKakao() {
|
||||
Kakao.Auth.login({
|
||||
success: function (authObj) {
|
||||
location.href = "https://www.ynicte.com/Account/KakaoCallback"
|
||||
},
|
||||
fail: function (err) {
|
||||
alert("카카오 아이디로 로그인에 실패했습니다.");
|
||||
console.log(JSON.stringify(err))
|
||||
},
|
||||
Kakao.Auth.login({
|
||||
success: function (authObj) {
|
||||
location.href = "https://www.ynicte.com/Account/KakaoCallback"
|
||||
},
|
||||
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/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">
|
||||
|
|
@ -72,7 +76,7 @@ else
|
|||
<ul class="jnNum">
|
||||
<li><input type="text" id="userpno1" maxlength="6" class="int nocomma" value="@(!string.IsNullOrEmpty(Model.User.birthday) && Model.User.birthday.Length > 3 ? (Model.User.birthday ?? "").Substring(2) : "")" @(!string.IsNullOrEmpty(Model.User.birthday) ? Html.Raw("readonly=\"\" style=\"background-color:#ddd;\"") : Html.Raw(""))></li>
|
||||
<li>-</li>
|
||||
<li><input type="tel" id="userpno2" maxlength="7" class="int nocomma" placeholder="주민등록번호 뒤 7자리"></li>
|
||||
<li><input type="tel" id="userpno2" maxlength="7" class="int nocomma" placeholder="주민등록번호 뒤 7자리"></li>
|
||||
</ul>
|
||||
</li>
|
||||
@*인증완료상태여도 재인증 가능*@
|
||||
|
|
@ -126,163 +130,176 @@ else
|
|||
@section scriptsHeader{
|
||||
@Html.Partial("./Partial/ScriptPost")
|
||||
}
|
||||
@section scripts{
|
||||
<script>
|
||||
function bindassign(v) {
|
||||
$("#asno").val(v.split(':')[0]);
|
||||
$("#asname").val(v.split(':')[1]);
|
||||
<script>
|
||||
function bindassign(v) {
|
||||
$("#asno").val(v.split(':')[0]);
|
||||
$("#asname").val(v.split(':')[1]);
|
||||
}
|
||||
$(document).ready(function () {
|
||||
if ('@(ViewBag.JoinOK?1:0)' == '1') {
|
||||
$("#pageTitle h3").text("회원가입 완료");
|
||||
}
|
||||
$(document).ready(function () {
|
||||
if ('@(ViewBag.JoinOK?1:0)' == '1') {
|
||||
$("#pageTitle h3").text("회원가입 완료");
|
||||
}
|
||||
});
|
||||
function save() {
|
||||
setv("userid", val("userid").replace(/ /, '').replace(/ /, ''));
|
||||
setv("userpno", val("userpno1").replace(/ /, '').replace(/ /, '') + "" + val("userpno2").replace(/ /, '').replace(/ /, ''));
|
||||
setv("userpass", val("userpass").replace(/ /, '').replace(/ /, ''));
|
||||
setv("username", val("username").replace(/ /, '').replace(/ /, ''));
|
||||
setv("email", val("email").replace(/ /, '').replace(/ /, ''));
|
||||
setv("mobile", val("mobile").replace(/ /, '').replace(/ /, ''));
|
||||
setv("mobile", formatmobile(val("mobile")));
|
||||
//var userid = val("userid").replace(/[^(0-9a-zA-Z)]/gi, '');
|
||||
if (check("username", null, "이름을 입력해주세요.")) { }
|
||||
else if (check("email", null, "이메일주소를 입력해주세요.")) { }
|
||||
else if (!isemail(val("email"))) { focus("email"); msg("올바른 이메일주소를 입력해주세요."); }
|
||||
else if (check("userid", null, "아이디를 입력해주세요.")) { }
|
||||
else if (getBytes(val("userid")) < 5) { focus("userid"); msg("(5자이상, 영문/숫자/-/_) 규칙으로 아이디를 입력해주세요."); }
|
||||
else if (!isid(val("userid"))) { focus("userid"); msg("(5자이상, 영문/숫자/-/_) 규칙으로 아이디를 입력해주세요."); }
|
||||
else if (val("IsSaveOK") != 1) { focus("userid"); msg("중복여부체크를 진행해주세요"); }
|
||||
else if (check("userpass", null, "비밀번호를 입력해주세요.")) { }
|
||||
else if (!ispassword(val("userpass"))) { focus("userpass"); msg("(8자 이상, 영문/숫자/특수기호 포함) 규칙으로 비밀번호를 입력해주세요."); }
|
||||
else if (val("userpass") != val("userpass2")) { focus("userpass2"); msg("비밀번호 확인이 다릅니다."); }
|
||||
else if (check("userpno", null, "주민등록번호를 입력해주세요")) { }
|
||||
else if (getBytes(val("userpno1")) != 6 || getBytes(val("userpno2")) != 7) { focus("userpno2"); msg("주민등록번호를 확인해주세요"); }
|
||||
else if (!ismobilenumber(val("mobile"))) {focus("mobile");msg("핸드폰번호를 확인해주세요.");}
|
||||
else if (check("post", null, "우편번호를 등록해주세요.") || check("address1", null, "우편번호를 등록해주세요.") || check("address2", null, "우편번호를 등록해주세요.")) { }
|
||||
else if (check("asno", null, "직장을 등록해주세요.")) { }
|
||||
else if ($("input:radio[name='isassignuser']:checked").val() == null) { msg("채용형태를 선택해주세요"); }
|
||||
else if (check("uduty", null, "직위를 입력해주세요.")) { }
|
||||
else if ($("input:radio[name='slevel']:checked").val() == null) { msg("학력을 선택해주세요"); }
|
||||
else if (!$("#agree").prop("checked")) { $("#agree").focus(); msg("이용약관/개인정보처리방침에 동의해주세요."); }
|
||||
else {
|
||||
cap("/focommon/join", "mform", "cbsave");
|
||||
}
|
||||
snsLogin();
|
||||
});
|
||||
function save() {
|
||||
setv("userid", val("userid").replace(/ /, '').replace(/ /, ''));
|
||||
setv("userpno", val("userpno1").replace(/ /, '').replace(/ /, '') + "" + val("userpno2").replace(/ /, '').replace(/ /, ''));
|
||||
setv("userpass", val("userpass").replace(/ /, '').replace(/ /, ''));
|
||||
setv("username", val("username").replace(/ /, '').replace(/ /, ''));
|
||||
setv("email", val("email").replace(/ /, '').replace(/ /, ''));
|
||||
setv("mobile", val("mobile").replace(/ /, '').replace(/ /, ''));
|
||||
setv("mobile", formatmobile(val("mobile")));
|
||||
//var userid = val("userid").replace(/[^(0-9a-zA-Z)]/gi, '');
|
||||
if (check("username", null, "이름을 입력해주세요.")) { }
|
||||
else if (check("email", null, "이메일주소를 입력해주세요.")) { }
|
||||
else if (!isemail(val("email"))) { focus("email"); msg("올바른 이메일주소를 입력해주세요."); }
|
||||
else if (check("userid", null, "아이디를 입력해주세요.")) { }
|
||||
else if (getBytes(val("userid")) < 5) { focus("userid"); msg("(5자이상, 영문/숫자/-/_) 규칙으로 아이디를 입력해주세요."); }
|
||||
else if (!isid(val("userid"))) { focus("userid"); msg("(5자이상, 영문/숫자/-/_) 규칙으로 아이디를 입력해주세요."); }
|
||||
else if (val("IsSaveOK") != 1) { focus("userid"); msg("중복여부체크를 진행해주세요"); }
|
||||
else if (check("userpass", null, "비밀번호를 입력해주세요.")) { }
|
||||
else if (!ispassword(val("userpass"))) { focus("userpass"); msg("(8자 이상, 영문/숫자/특수기호 포함) 규칙으로 비밀번호를 입력해주세요."); }
|
||||
else if (val("userpass") != val("userpass2")) { focus("userpass2"); msg("비밀번호 확인이 다릅니다."); }
|
||||
else if (check("userpno", null, "주민등록번호를 입력해주세요")) { }
|
||||
else if (getBytes(val("userpno1")) != 6 || getBytes(val("userpno2")) != 7) { focus("userpno2"); msg("주민등록번호를 확인해주세요"); }
|
||||
else if (!ismobilenumber(val("mobile"))) {focus("mobile");msg("핸드폰번호를 확인해주세요.");}
|
||||
else if (check("post", null, "우편번호를 등록해주세요.") || check("address1", null, "우편번호를 등록해주세요.") || check("address2", null, "우편번호를 등록해주세요.")) { }
|
||||
else if (check("asno", null, "직장을 등록해주세요.")) { }
|
||||
else if ($("input:radio[name='isassignuser']:checked").val() == null) { msg("채용형태를 선택해주세요"); }
|
||||
else if (check("uduty", null, "직위를 입력해주세요.")) { }
|
||||
else if ($("input:radio[name='slevel']:checked").val() == null) { msg("학력을 선택해주세요"); }
|
||||
else if (!$("#agree").prop("checked")) { $("#agree").focus(); msg("이용약관/개인정보처리방침에 동의해주세요."); }
|
||||
else {
|
||||
cap("/focommon/join", "mform", "cbsave");
|
||||
}
|
||||
function idcheck() {
|
||||
if (check("userid", null, "아이디를 입력해주세요.")) { }
|
||||
else if (getBytes(val("userid")) < 5) { focus("userid"); msg("(5자이상, 영문/숫자/-/_) 규칙으로 아이디를 입력해주세요."); }
|
||||
else if (!isid(val("userid"))) { focus("userid"); msg("(5자이상, 영문/숫자/-/_) 규칙으로 아이디를 입력해주세요."); }
|
||||
else {
|
||||
capp("/focommon/idchk", { id: val("userid") }, "cbidchk");
|
||||
}
|
||||
}
|
||||
function idcheck() {
|
||||
if (check("userid", null, "아이디를 입력해주세요.")) { }
|
||||
else if (getBytes(val("userid")) < 5) { focus("userid"); msg("(5자이상, 영문/숫자/-/_) 규칙으로 아이디를 입력해주세요."); }
|
||||
else if (!isid(val("userid"))) { focus("userid"); msg("(5자이상, 영문/숫자/-/_) 규칙으로 아이디를 입력해주세요."); }
|
||||
else {
|
||||
capp("/focommon/idchk", { id: val("userid") }, "cbidchk");
|
||||
}
|
||||
}
|
||||
|
||||
function cbidchk() {
|
||||
if (capResult.code == 1000) {
|
||||
setv("IsSaveOK", 1);
|
||||
msg("사용가능한 아이디입니다.");
|
||||
} else {
|
||||
focus("userid");
|
||||
msg("이미 사용중인 아이디입니다.<br />다른 아이디를 사용해주세요.");
|
||||
}
|
||||
function cbidchk() {
|
||||
if (capResult.code == 1000) {
|
||||
setv("IsSaveOK", 1);
|
||||
msg("사용가능한 아이디입니다.");
|
||||
} else {
|
||||
focus("userid");
|
||||
msg("이미 사용중인 아이디입니다.<br />다른 아이디를 사용해주세요.");
|
||||
}
|
||||
}
|
||||
|
||||
function cbsave() {
|
||||
if (capResult.code == 1000) {
|
||||
setv("intval", 1);
|
||||
$("#mform").submit();
|
||||
}
|
||||
else if (capResult.obj == -1) {
|
||||
focus("userid");
|
||||
msg("이미 사용중인 아이디입니다.<br />다른 아이디를 사용해주세요.");
|
||||
}
|
||||
else if (capResult.obj == -2) {
|
||||
focus("email");
|
||||
msg("이미 사용중인 이메일입니다.<br />다른 이메일을 사용해주세요.");
|
||||
}
|
||||
else if (capResult.obj == -3) {
|
||||
focus("mobile");
|
||||
msg("이미 사용중인 핸드폰번호입니다.<br />다른 번호를 사용해주세요.");
|
||||
}
|
||||
function cbsave() {
|
||||
if (capResult.code == 1000) {
|
||||
setv("intval", 1);
|
||||
$("#mform").submit();
|
||||
}
|
||||
|
||||
function mobchk() {
|
||||
//한번 인증되면 재인증 불가
|
||||
if ($("#intval2").val() == 1 && $("#mobile").val() != null) {
|
||||
msg("휴대폰 인증이 완료되었습니다.");
|
||||
} else {
|
||||
mobilechkview('MCHK');
|
||||
}
|
||||
else if (capResult.obj == -1) {
|
||||
focus("userid");
|
||||
msg("이미 사용중인 아이디입니다.<br />다른 아이디를 사용해주세요.");
|
||||
}
|
||||
else if (capResult.obj == -2) {
|
||||
focus("email");
|
||||
msg("이미 사용중인 이메일입니다.<br />다른 이메일을 사용해주세요.");
|
||||
}
|
||||
else if (capResult.obj == -3) {
|
||||
focus("mobile");
|
||||
msg("이미 사용중인 핸드폰번호입니다.<br />다른 번호를 사용해주세요.");
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('load', function () {
|
||||
if (@Request["jointype"] == "2") {
|
||||
var naverLogin = new naver.LoginWithNaverId(
|
||||
{
|
||||
clientId: "@naverClientId",
|
||||
callbackUrl: "https://www.ynicte.com/Account/Join?jointype=2",
|
||||
isPopup: false,
|
||||
callbackHandle: true
|
||||
function mobchk() {
|
||||
//한번 인증되면 재인증 불가
|
||||
if ($("#intval2").val() == 1 && $("#mobile").val() != null) {
|
||||
msg("휴대폰 인증이 완료되었습니다.");
|
||||
} else {
|
||||
mobilechkview('MCHK');
|
||||
}
|
||||
}
|
||||
|
||||
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(
|
||||
{
|
||||
clientId: "@naverClientId",
|
||||
callbackUrl: "https://www.ynicte.com/Account/Join?jointype=2",
|
||||
isPopup: false,
|
||||
callbackHandle: true
|
||||
}
|
||||
);
|
||||
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;
|
||||
}
|
||||
);
|
||||
|
||||
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").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 {
|
||||
alert("callback 처리에 실패하였습니다. 관리자에게 문의하세요. error status[" + status + "]");
|
||||
history.back(-1);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (@Request["jointype"] == "3") {
|
||||
$.when(
|
||||
Kakao.init("@kakaoClientId"),
|
||||
).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");
|
||||
} else {
|
||||
console.log("callback 처리에 실패하였습니다.");
|
||||
},
|
||||
fail: function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (@Request["jointype"] == "3") {
|
||||
$.when(
|
||||
Kakao.init("@kakaoAppkey"),
|
||||
).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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</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",
|
||||
|
|
@ -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");
|
||||
}
|
||||
</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