Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cb 함수가 동작하지 않습니다. #5

Open
ParkDyel opened this issue Jun 24, 2020 · 2 comments
Open

cb 함수가 동작하지 않습니다. #5

ParkDyel opened this issue Jun 24, 2020 · 2 comments

Comments

@ParkDyel
Copy link

image

NaverLogin 컴포넌트에 전달된 :callbackFuncition은 어떤식으로 동작시켜야 하는걸까요?
위와 같은 방식으로 진행했을 때는 코드가 동작하지 않는 것처럼 느껴졌습니다.

@ParkDyel
Copy link
Author

해보고자 했던것은 Vue에서 Naver로 로그인한 뒤 userId 값을 localStorage에 저장하는 것이었습니다.

@wonyongHwang
Copy link

wonyongHwang commented Jan 11, 2022

지나가다 첨언드립니다.
저 같은 경우는,
아래와 같이 NaverLogin.vue를 수정하고,

window.addEventListener('load', function () {
this.naverLogin.getLoginStatus(function (status) {
this.isLoggedIn = status;
const info = {
id: this.naverLogin.user.id,
age: this.naverLogin.user.age,
gender: this.naverLogin.user.gender,
email: this.naverLogin.user.email,
nickname: this.naverLogin.user.nickname,
profile_image: this.naverLogin.user.profile_image,
}
console.log(info)
return comp.callbackFunction(status, info, this.naverLogin.accessToken.accessToken);
}.bind(this));
}.bind(this));

NaverLogin의 상위 컴포넌트의 콜백함수에서 위에서 넘겨진 info를 이용하여 처리하였습니다
naverCallback(status, info, token) {
if (status) {
/* (5) 필수적으로 받아야하는 프로필 정보가 있다면 callback처리 시점에 체크 /
var email = info.email;
if( email == undefined || email == null) {
alert("이메일은 필수정보입니다. 정보제공을 동의해주세요.");
/
(5-1) 사용자 정보 재동의를 위하여 다시 네아로 동의페이지로 이동함 */
// this.naverLogin.reprompt();
this.$router.push({ path: '/'});
return;
}
console.log("naver token : "+ token);
this.acToken = token;
this.CallBackend(info.email, this.acToken, 0, 'naver');
// window.location.replace("http://" + window.location.hostname + ( (location.port==""||location.port==undefined)?"":":" + location.port) + "/sample/main.html");
} else {
console.log("callback 처리에 실패하였습니다.");
}
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants