Skip to content

Commit

Permalink
fixed Issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidiumihaibelciug committed Dec 8, 2019
1 parent 30191c4 commit 858cce5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/pages/post.js
@@ -1,6 +1,18 @@
import React, { Component } from 'react';
import Layout from '../utils/layout';
import PostBase from '../components/scenes/Post/Post';
import { compose } from 'recompose';
import {
withAuthorization,
withEmailVerification,
} from '../utils/Session';

const condition = authUser => !!authUser;

const PostPage = compose(
withEmailVerification,
withAuthorization(condition),
)(PostBase);

export class Post extends Component {
render() {
Expand All @@ -10,7 +22,7 @@ export class Post extends Component {

return (
<Layout>
<PostBase
<PostPage
title={title}
description={description}
slug={this.props['*']}
Expand Down
14 changes: 13 additions & 1 deletion src/templates/post.js
@@ -1,6 +1,18 @@
import React, { Component } from 'react';
import Layout from '../utils/layout';
import PostBase from '../components/scenes/Post/Post';
import { compose } from 'recompose';
import {
withAuthorization,
withEmailVerification,
} from '../utils/Session';

const condition = authUser => !!authUser;

const PostPage = compose(
withEmailVerification,
withAuthorization(condition),
)(PostBase);

export class Post extends Component {
render() {
Expand All @@ -17,7 +29,7 @@ export class Post extends Component {

return (
<Layout>
<PostBase
<PostPage
title={title}
description={description}
slug={slug || uriSlug}
Expand Down
4 changes: 4 additions & 0 deletions src/utils/Session/withAuthorization.js
Expand Up @@ -13,8 +13,12 @@ const withAuthorization = condition => Component => {
if (this.props.firebase && !this._initFirebase) {
this._initFirebase = true;

console.log('test');

this.listener = this.props.firebase.onAuthUserListener(
authUser => {
console.log('test');

if (!condition(authUser)) {
navigate(SIGN_IN);
}
Expand Down

0 comments on commit 858cce5

Please sign in to comment.