Skip to content

Commit 53d49dd

Browse files
authored
Merge pull request #46 from CreateThrive/feature/microsoft-auth
Feature: Microsoft authentication
2 parents c4feb30 + fc52d74 commit 53d49dd

4 files changed

Lines changed: 25 additions & 6 deletions

File tree

database.rules.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"rules": {
33
"users": {
44
"$user": {
5-
".write": "auth !== null && (auth.token.email_verified === true || auth.provider === 'facebook') && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)",
6-
".read": "auth !== null && (auth.token.email_verified === true || auth.provider === 'facebook') && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)"
5+
".write": "auth !== null && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)",
6+
".read": "auth !== null && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)"
77
},
8-
".write": "auth !== null && (auth.token.email_verified === true || auth.provider === 'facebook') && auth.token.isAdmin === true",
9-
".read": "auth !== null && (auth.token.email_verified === true || auth.provider === 'facebook') && auth.token.isAdmin === true"
8+
".write": "auth !== null && auth.token.isAdmin === true",
9+
".read": "auth !== null && auth.token.isAdmin === true"
1010
}
1111
}
1212
}

src/pages/Login/Login.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ beforeEach(() => {
4747
jest.spyOn(reactRedux, 'useDispatch').mockImplementation(() => dispatchMock);
4848
jest.spyOn(authActions, 'authFacebook').mockImplementation(jest.fn);
4949
jest.spyOn(authActions, 'authGoogle').mockImplementation(jest.fn);
50+
jest.spyOn(authActions, 'authMicrosoft').mockImplementation(jest.fn);
5051
});
5152

5253
it('should dispatch authFacebook action when the user tries to log in with Facebook', () => {
@@ -72,3 +73,15 @@ it('should dispatch authGoogle action when the user tries to log in with Google'
7273

7374
expect(authActions.authGoogle).toHaveBeenCalled();
7475
});
76+
77+
it('should dispatch authMicrosoft action when the user tries to log in with Microsoft', () => {
78+
const { component } = mountWithProviders(<Login />)({
79+
auth: {
80+
userData: {}
81+
}
82+
});
83+
84+
component.find('#microsoft').simulate('click');
85+
86+
expect(authActions.authMicrosoft).toHaveBeenCalled();
87+
});

src/pages/Login/index.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
setPassword,
1313
authCleanUp,
1414
authFacebook,
15-
authGoogle
15+
authGoogle,
16+
authMicrosoft
1617
} from 'state/actions/auth';
1718
import { useChangeHandler, useFormatMessage } from 'hooks';
1819
import { inputValidations } from 'utils';
@@ -80,7 +81,7 @@ const Login = () => {
8081
};
8182

8283
const onMicrosoftHandler = () => {
83-
alert('Coming soon');
84+
dispatch(authMicrosoft());
8485
};
8586

8687
const inputs = isEmailLink

src/state/actions/auth.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,8 @@ export const authGoogle = () => {
314314
provider.addScope('https://www.googleapis.com/auth/userinfo.email');
315315
return authWithProvider(provider);
316316
};
317+
318+
export const authMicrosoft = () => {
319+
const provider = new firebase.auth.OAuthProvider('microsoft.com');
320+
return authWithProvider(provider);
321+
};

0 commit comments

Comments
 (0)