-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(popups): popup for oauth direct link and login menu
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |