-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
123 additions
and
49 deletions.
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
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 was deleted.
Oops, something went wrong.
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,23 @@ | ||
import React from 'react'; | ||
|
||
import { useSelector } from 'react-redux'; | ||
|
||
import { isAdmin } from '../store/reducers/accounts'; | ||
|
||
import Forbidden from '../pages/Forbidden'; | ||
|
||
export default function (Component) { | ||
return function AdminComponent(props) { | ||
const admin = useSelector(isAdmin); | ||
|
||
if (admin) { | ||
return ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<Component {...props} /> | ||
); | ||
} | ||
|
||
// return null; | ||
return <Forbidden />; | ||
}; | ||
} |
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,26 @@ | ||
import React from 'react'; | ||
|
||
import { useSelector } from 'react-redux'; | ||
import { useHistory, useLocation } from 'react-router-dom'; | ||
|
||
import { getIsAuthenticated } from '../store/reducers/auth'; | ||
|
||
export default function (Component) { | ||
return function AuthenticatedComponent(props) { | ||
const history = useHistory(); | ||
const location = useLocation(); | ||
const authenticated = useSelector(getIsAuthenticated); | ||
|
||
React.useEffect(() => { | ||
if (!authenticated) { | ||
const nextLocation = (location.pathname !== '/') ? location.pathname : '/files'; | ||
history.push(`/signin?next=${nextLocation}`); | ||
} | ||
}, [authenticated, location.pathname, history]); | ||
|
||
return ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<Component {...props} /> | ||
); | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
|
||
import { useHistory } from 'react-router-dom'; | ||
|
||
import * as icons from '../icons'; | ||
|
||
import Button from '../components/ui/Button'; | ||
|
||
function Forbidden() { | ||
const history = useHistory(); | ||
|
||
return ( | ||
<div className="fixed inset-0 bg-white z-50"> | ||
<div className="flex flex-col items-center justify-center min-h-screen space-y-8"> | ||
<h1 className="text-3xl"> | ||
Forbidden | ||
</h1> | ||
<Button | ||
type="text" | ||
size="lg" | ||
icon={<icons.ArrowLeft />} | ||
title="Go back" | ||
onClick={() => history.push('/')} | ||
> | ||
Go home | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Forbidden; |
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,11 @@ | ||
import React from 'react'; | ||
|
||
function UserManagement() { | ||
return ( | ||
<div> | ||
User Management | ||
</div> | ||
); | ||
} | ||
|
||
export default UserManagement; |
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