This repository has been archived by the owner on Jun 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 362
Devise Token Auth for one quran #571
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,34 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
|
||
import { save } from 'redux/actions/auth'; | ||
import { push } from 'react-router-redux'; | ||
|
||
const styles = require('./style.scss'); | ||
|
||
const FacebookTokenButton = ({ save, push }) => { // eslint-disable-line | ||
let popup = null; | ||
let interval = null; | ||
|
||
const handleClick = () => { | ||
popup = window.open('/onequran/omniauth/facebook?omniauth_window_type=newWindow&resource_class=User', '_blank'); // eslint-disable-line | ||
interval = setInterval(() => popup.postMessage('requestCredentials', '*'), 1000); | ||
|
||
window.addEventListener('message', (event) => { // eslint-disable-line | ||
if (event.data.uid) { | ||
save(event.data); | ||
clearInterval(interval); | ||
|
||
return push('/'); | ||
} | ||
}, false); | ||
}; | ||
|
||
return ( | ||
<button onClick={handleClick} className={`${styles.button} btn btn-default btn-block btn-lg`}> | ||
<i className="fa fa-facebook" /> Continue with Facebook | ||
</button> | ||
); | ||
}; | ||
|
||
export default connect(null, { save, push })(FacebookTokenButton); |
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,6 @@ | ||
.button{ | ||
background: #3B5998; | ||
border-color: #3B5998; | ||
color: #fff; | ||
font-weight: 300; | ||
} |
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
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 |
---|---|---|
@@ -1,9 +1,28 @@ | ||
import React from 'react'; | ||
|
||
import FacebookButton from 'components/FacebookButton'; | ||
import FacebookTokenButton from 'components/FacebookTokenButton'; | ||
import LocaleFormattedMessage from 'components/LocaleFormattedMessage'; | ||
|
||
const logo = require('../../../static/images/logo-lg.png'); | ||
|
||
export default () => ( | ||
<div> | ||
<FacebookButton /> | ||
<div className="row" style={{ paddingTop: '10vh' }}> | ||
<div className="col-md-4 col-md-offset-4"> | ||
<div className="panel panel-default"> | ||
<div className="panel-body"> | ||
<div className="text-center"> | ||
<img src={logo} alt="logo" width="30%" /> | ||
<h3 style={{ color: '#000' }}>Quran.com</h3> | ||
</div> | ||
<p> | ||
<LocaleFormattedMessage | ||
id="login.message" | ||
default="Sign in to Quran.com to store all your bookmarks, notes and activities." | ||
/> | ||
</p> | ||
<FacebookTokenButton /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); |
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -5,7 +5,8 @@ import { | |
FACEBOOK_FAILURE, | ||
LOGOUT_SUCCESS, | ||
LOAD_SUCCESS, | ||
LOAD_FAILURE | ||
LOAD_FAILURE, | ||
SAVE | ||
} from 'redux/constants/auth'; | ||
|
||
const initialState = { | ||
|
@@ -14,6 +15,22 @@ const initialState = { | |
|
||
export default function reducer(state = initialState, action = {}) { | ||
switch (action.type) { | ||
case SAVE: { | ||
cookie.save('auth', { | ||
client: action.data.client_id, | ||
'access-token': action.data.auth_token, | ||
expiry: action.data.expiry, | ||
uid: action.data.uid, | ||
'token-type': 'Bearer' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alignment of these properties. |
||
}); | ||
|
||
return { | ||
...state, | ||
loading: false, | ||
loaded: true, | ||
user: action.data | ||
}; | ||
} | ||
case LOAD_SUCCESS: | ||
return { | ||
...state, | ||
|
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 |
---|---|---|
|
@@ -28,6 +28,10 @@ html,body{ | |
} | ||
} | ||
|
||
.min-container{ | ||
min-height: 80vh; | ||
} | ||
|
||
.highlight { | ||
background-color: #F5FBF7; | ||
} | ||
|
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
export default function isValidSurah(nextState, replaceState) { | ||
const surahId = parseInt(nextState.params.surahId, 10); | ||
|
||
if (isNaN(surahId) || surahId > 114 || surahId < 1) { | ||
replaceState('/error/invalid-surah'); | ||
} | ||
// if (isNaN(surahId) || surahId > 114 || surahId < 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ooops! |
||
// replaceState('/error/invalid-surah'); | ||
// } | ||
|
||
if (nextState.params.range) { | ||
if (nextState.params.range.includes('-')) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a less generic event name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the
window.postMessage
event name :(