WIP
This commit is contained in:
40
src/routes/Admin.js
Normal file
40
src/routes/Admin.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import React from 'react';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import { auth } from '../rebase';
|
||||
|
||||
class Admin extends React.Component {
|
||||
renderInsufficientAccess = () => {
|
||||
return (
|
||||
<div>
|
||||
<p>You have insufficient access.</p>
|
||||
<p>Click <a onClick={this.logout}>Here</a> to log in again.</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
logout = () => {
|
||||
auth.signOut();
|
||||
}
|
||||
|
||||
render() {
|
||||
const logout = <button onClick={this.logout}>Logout</button>;
|
||||
|
||||
if (!this.props.user.uid) {
|
||||
return <Redirect to={{ pathname: '/login' }} />
|
||||
}
|
||||
if (!this.props.user.data.isAdmin) {
|
||||
return this.renderInsufficientAccess();
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Admin</h1>
|
||||
<img src={this.props.user.photoURL} alt={this.props.user.displayName} />
|
||||
<p>Hello, {this.props.user.displayName}</p>
|
||||
{logout}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Admin;
|
||||
Reference in New Issue
Block a user