Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
test case to assert apple provider | created const to hold the lower …
…case provider name | check for apple.com | pass down providerName to OAuthProvider when microsoft or apple | added apple to supportedAuthProviders
  • Loading branch information
davidepalazzo committed Jul 24, 2020
commit 3db699cf2c0f9e7e01f5bec217da43df26bdabd1
3 changes: 2 additions & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ export const supportedAuthProviders = [
'github',
'twitter',
'facebook',
'microsoft.com'
'microsoft.com',
'apple.com'
]

/**
Expand Down
11 changes: 8 additions & 3 deletions src/utils/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ function createAuthProvider(firebase, providerName, scopes) {
// TODO: Verify scopes are valid before adding
// TODO: Validate parameter inputs

if (providerName.toLowerCase() === 'microsoft.com') {
const provider = new firebase.auth.OAuthProvider('microsoft.com')
const lowerCaseProviderName = providerName.toLowerCase()

if (
lowerCaseProviderName === 'microsoft.com' ||
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most likely going to update this to be an array instead of multiple if conditions since that will also make it easy to add to the list:

['microsoft.com', 'apple.com', 'yahoo.com'].includes(lowerCaseProviderName)

lowerCaseProviderName === 'apple.com'
) {
const provider = new firebase.auth.OAuthProvider(providerName)
return provider
}

Expand All @@ -38,7 +43,7 @@ function createAuthProvider(firebase, providerName, scopes) {

// Handle providers without scopes
if (
providerName.toLowerCase() === 'twitter' ||
lowerCaseProviderName === 'twitter' ||
typeof provider.addScope !== 'function'
) {
return provider
Expand Down
6 changes: 6 additions & 0 deletions test/unit/utils/auth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ describe('Utils: Auth', () => {
).to.include.keys('method')
})

it('apple.com provider', () => {
expect(
getLoginMethodAndParams(firebase, { provider: 'apple.com' })
).to.include.keys('method')
})

it('token', () => {
expect(
getLoginMethodAndParams(firebase, { token: 'asdf' })
Expand Down