Skip to content

Commit b347681

Browse files
committed
Support IE by redirect link to LinkedInPopUp
1 parent 0be6443 commit b347681

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

demo/src/LinkedInPage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class LinkedInPage extends Component {
3333
state="34232423"
3434
onFailure={this.handleFailure}
3535
onSuccess={this.handleSuccess}
36+
supportIE
37+
redirectPath='/linkedin'
3638
>
3739
<img src={require('./assets/linkedin.png')} alt="Log in with Linked In" style={{ maxWidth: '180px' }} />
3840
</LinkedIn>

src/LinkedIn.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ export class LinkedIn extends Component {
2020
}
2121

2222
getUrl = () => {
23-
const {redirectUri, clientId, state, scope} = this.props;
23+
const {redirectUri, clientId, state, scope, supportIE, redirectPath } = this.props;
2424
// TODO: Support IE 11
25-
const scopeParam = (scope) ? `&scope=${encodeURI(scope)}` : ''
25+
const scopeParam = (scope) ? `&scope=${supportIE ? scope : encodeURI(scope)}` : '';
2626
const linkedInAuthenLink = `https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=${clientId}&redirect_uri=${redirectUri}${scopeParam}&state=${state}`;
27+
if (supportIE) {
28+
const redirectLink = `${window.location.origin}${redirectPath}?linkedin_redirect_url=${encodeURIComponent(linkedInAuthenLink)}`;
29+
return redirectLink;
30+
}
2731
return linkedInAuthenLink;
2832
}
2933

@@ -85,5 +89,7 @@ LinkedIn.defaultProps = {
8589
disabled: false,
8690
children: (<img src={require('../assets/linkedin.png')} alt="Log in with Linked In" style={{ maxWidth: '180px' }} />),
8791
state: 'fdsf78fyds7fm',
92+
supportIE: false,
93+
redirectPath: '/linkedin'
8894
};
8995
export default LinkedIn;

src/LinkedInPopUp.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class LinkedInPopUp extends Component {
1515
if (params.code) {
1616
window.opener && window.opener.postMessage({ code: params.code, state: params.state, from: 'Linked In'}, window.location.origin);
1717
}
18+
if(params.linkedin_redirect_url) {
19+
window.location.href = params.linkedin_redirect_url
20+
}
1821
}
1922
render() {
2023
return null;

0 commit comments

Comments
 (0)