Skip to content

Commit

Permalink
feat(popups): popup for oauth direct link and login menu
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed Aug 22, 2019
1 parent 7d4f438 commit 1c97122
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/methods/popup-login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default (self, enableSkip, baseUri = 'https://passport.e-com.plus/v1/') => {
let url = `${baseUri}${self.lang}/${self.storeId}/${self.sessionId}/login.html`
if (enableSkip) {
// shows link to skip social login
url += '?enable_skip=true'
}
return self.popupOauthLink(url)
}
34 changes: 34 additions & 0 deletions src/methods/popup-oauth-link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import createPopup from './../lib/create-popup'

export default (self, url) => {
let popupWatch = null

const getCustomerInfo = fromCallback => {
// run after login
clearInterval(popupWatch)
// store customer public info and authentication session
self.fetchOauthProfile()
}

// public callback function
window.passportCallback = function () {
// logged
getCustomerInfo(true)
}

const popup = createPopup(url)
if (popup) {
if (typeof window === 'object' && window.focus) {
popup.focus()
}
// close fallback
popupWatch = setInterval(() => {
if (popup.closed) {
// may be logged
getCustomerInfo(false)
}
}, 400)
}

return popup
}

0 comments on commit 1c97122

Please sign in to comment.