-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ht1 #3
base: master
Are you sure you want to change the base?
Ht1 #3
Conversation
return <Component {...props} />; | ||
} | ||
|
||
return <Redirect to="/auth"/>; |
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.
Может Redirect не лучший выбор в данном случае, так ты будешь всегда сначала на auth попадать
@@ -27,7 +28,15 @@ export default function reducer(state = new ReducerRecord(), action) { | |||
switch (type) { | |||
case SIGN_IN_SUCCESS: | |||
case SIGN_UP_SUCCESS: | |||
return state.set('user', payload.user) | |||
case START_SESSION: | |||
localStorage.setItem('token', payload.user.email) |
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.
в редюсере сайдэффекты делать - плохая практика
} else if (localStorage.getItem('token') !== undefined) { | ||
const user = localStorage.getItem('token'); | ||
console.log(user); | ||
dispatch({ |
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.
Если уже хочешь заморачиваться с токенами - их тоже инвалидировать надо иногда
через пару часов доделаю последний обязатнльный пункт по тесту :(
сейчас не возможносьи , даже пулреквест с мобилки сделал .
https://github.com/romabelka/adv-react-290
спасибо...
пн, 4 февр. 2019 г., 23:06 Roman <[email protected]>:
… ***@***.**** commented on this pull request.
------------------------------
In admin/src/components/routes/AuthRoute.js
<#3 (comment)>
:
> +class AuthRoute extends Component {
+ render() {
+ const {component, ...rest} = this.props;
+
+ return <Route {...rest} render={this.renderComponent}/>;
+ }
+
+ renderComponent = props => {
+ const {component: Component, isAuth} = this.props;
+ console.log('isAuth = ',isAuth);
+
+ if (isAuth) {
+ return <Component {...props} />;
+ }
+
+ return <Redirect to="/auth"/>;
Может Redirect не лучший выбор в данном случае, так ты будешь всегда
сначала на auth попадать
------------------------------
In admin/src/ducks/auth.js
<#3 (comment)>
:
> @@ -27,7 +28,15 @@ export default function reducer(state = new ReducerRecord(), action) {
switch (type) {
case SIGN_IN_SUCCESS:
case SIGN_UP_SUCCESS:
- return state.set('user', payload.user)
+ case START_SESSION:
+ localStorage.setItem('token', payload.user.email)
в редюсере сайдэффекты делать - плохая практика
------------------------------
In admin/src/ducks/auth.js
<#3 (comment)>
:
> +export const START_SESSION = `${prefix}/START_SESSION`
+export const END_SESSION = `${prefix}/END_SESSION`
+
+export const checkAuth = () => {
+ return (dispatch) => {
+ firebase.auth().onAuthStateChanged((user) => {
+ console.log('--- user', user)
+ if (user) {
+ dispatch({
+ type: START_SESSION,
+ payload: {user}
+ })
+ } else if (localStorage.getItem('token') !== undefined) {
+ const user = localStorage.getItem('token');
+ console.log(user);
+ dispatch({
Если уже хочешь заморачиваться с токенами - их тоже инвалидировать надо
иногда
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AR4LbeOiRTiZYYm_9EzPMypf74f8D1n-ks5vKJKygaJpZM4agcmH>
.
|
через пару часов доделаю последний обязатнльный пункт по тесту :(
сейчас не возможносьи , даже пулреквест с мобилкaлал .
https://github.com/romabelka/adv-react-2901/pull/141
пн, 11 февр. 2019 г., 20:38 Вячеслав Ковалёв <[email protected]>:
… через пару часов доделаю последний обязатнльный пункт по тесту :(
сейчас не возможносьи , даже пулреквест с мобилкaлал .
https://github.com/romabelka/adv-react-290
спасибо...
пн, 4 февр. 2019 г., 23:06 Roman ***@***.***>:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In admin/src/components/routes/AuthRoute.js
> <#3 (comment)>
> :
>
> > +class AuthRoute extends Component {
>
> + render() {
>
> + const {component, ...rest} = this.props;
>
> +
>
> + return <Route {...rest} render={this.renderComponent}/>;
>
> + }
>
> +
>
> + renderComponent = props => {
>
> + const {component: Component, isAuth} = this.props;
>
> + console.log('isAuth = ',isAuth);
>
> +
>
> + if (isAuth) {
>
> + return <Component {...props} />;
>
> + }
>
> +
>
> + return <Redirect to="/auth"/>;
>
>
> Может Redirect не лучший выбор в данном случае, так ты будешь всегда
> сначала на auth попадать
> ------------------------------
>
> In admin/src/ducks/auth.js
> <#3 (comment)>
> :
>
> > @@ -27,7 +28,15 @@ export default function reducer(state = new ReducerRecord(), action) {
>
> switch (type) {
>
> case SIGN_IN_SUCCESS:
>
> case SIGN_UP_SUCCESS:
>
> - return state.set('user', payload.user)
>
> + case START_SESSION:
>
> + localStorage.setItem('token', payload.user.email)
>
>
> в редюсере сайдэффекты делать - плохая практика
> ------------------------------
>
> In admin/src/ducks/auth.js
> <#3 (comment)>
> :
>
> > +export const START_SESSION = `${prefix}/START_SESSION`
>
> +export const END_SESSION = `${prefix}/END_SESSION`
>
> +
>
> +export const checkAuth = () => {
>
> + return (dispatch) => {
>
> + firebase.auth().onAuthStateChanged((user) => {
>
> + console.log('--- user', user)
>
> + if (user) {
>
> + dispatch({
>
> + type: START_SESSION,
>
> + payload: {user}
>
> + })
>
> + } else if (localStorage.getItem('token') !== undefined) {
>
> + const user = localStorage.getItem('token');
>
> + console.log(user);
>
> + dispatch({
>
>
> Если уже хочешь заморачиваться с токенами - их тоже инвалидировать надо
> иногда
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#3 (review)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AR4LbeOiRTiZYYm_9EzPMypf74f8D1n-ks5vKJKygaJpZM4agcmH>
> .
>
|
No description provided.