Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/users/social/facebook.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Async from '../../request/async'
import Utils from '../../utils'

import { loginSocial } from './login'
import { sendSocialLoginRequest } from './request'
Expand All @@ -8,6 +9,8 @@ export const loginWithFacebook = (fieldsMapping, permissions, stayLoggedIn, asyn
}

export const loginWithFacebookSdk = (fieldsMapping, stayLoggedIn, options) => {
Utils.checkPromiseSupport()

return new Promise((resolve, reject) => {
if (!FB) {
return reject(new Error('Facebook SDK not found'))
Expand Down
3 changes: 3 additions & 0 deletions src/users/social/google.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Async from '../../request/async'
import Utils from '../../utils'

import { loginSocial } from './login'
import { sendSocialLoginRequest } from './request'
Expand All @@ -8,6 +9,8 @@ export const loginWithGooglePlus = (fieldsMapping, permissions, container, stayL
}

export const loginWithGooglePlusSdk = (fieldsMapping, stayLoggedIn) => {
Utils.checkPromiseSupport()

return new Promise((resolve, reject) => {
if (!gapi) {
return reject(new Error('Google Plus SDK not found'))
Expand Down
11 changes: 11 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ const Utils = {

promisified(method) {
return function() {
Utils.checkPromiseSupport()

const args = [].slice.call(arguments)
const context = this
const fn = typeof method === 'function' ? method : context[method]
Expand All @@ -170,6 +172,15 @@ const Utils = {

return fn.apply(context, arguments)
}
},

checkPromiseSupport() {
if (typeof Promise === 'undefined') {
throw new Error(
'This browser doesn\'t support Promise API. Please use polyfill.\n' +
'More info is in the Backendless JS-SDK docs: https://backendless.com/docs/js/doc.html#sync-and-async-calls'
)
}
}
}

Expand Down