only admin

This commit is contained in:
monoid 2021-01-15 22:06:05 +09:00
parent 29beb1dc80
commit 5171211f7a
3 changed files with 11 additions and 7 deletions

View File

@ -84,7 +84,7 @@ export const DocumentAbout = (prop: { match: MatchType }) => {
</Route> </Route>
<Route> <Route>
<Headline menu={menu_list()}> <Headline menu={menu_list()}>
<div>404 Not Found invalid url : {prop.match.path}</div> <Typography variant='h2'>404 Not Found invalid url : {prop.match.path}</Typography>
</Headline> </Headline>
</Route> </Route>
</Switch>); </Switch>);

View File

@ -3,6 +3,7 @@ import { CommonMenuList, Headline } from "../component/mod";
import { UserContext } from "../state"; import { UserContext } from "../state";
import { Grid, Paper, Typography } from "@material-ui/core"; import { Grid, Paper, Typography } from "@material-ui/core";
export function DifferencePage(){ export function DifferencePage(){
const ctx = useContext(UserContext); const ctx = useContext(UserContext);
const [diffList,setDiffList] = useState< const [diffList,setDiffList] = useState<
@ -41,11 +42,13 @@ export function DifferencePage(){
} }
} }
const menu = CommonMenuList(); const menu = CommonMenuList();
(ctx.username == "admin")
return (<Headline menu={menu}> return (<Headline menu={menu}>
{diffList.map(x=><Paper key={x.type}> {(ctx.username == "admin") ? (diffList.map(x=><Paper key={x.type}>
<Typography variant='h3'>{x.type}</Typography> <Typography variant='h3'>{x.type}</Typography>
{x.value.map(y=><Typography variant='h5' onClick={()=>Commit(y)}>{y.path}</Typography>)} {x.value.map(y=>(<Typography key={y.path} variant='h5' onClick={()=>Commit(y)}>{y.path}</Typography>))}
</Paper>)} </Paper>)):(<Typography variant='h2'>Not Allowed : please login as an admin</Typography>)
}
</Headline>) </Headline>)
} }

View File

@ -3,6 +3,7 @@ import Router from 'koa-router';
import { ContentFile } from '../content/mod'; import { ContentFile } from '../content/mod';
import { sendError } from '../route/error_handler'; import { sendError } from '../route/error_handler';
import {DiffManager} from './diff'; import {DiffManager} from './diff';
import {AdminOnlyMiddleware} from '../permission/permission';
function content_file_to_return(x:ContentFile){ function content_file_to_return(x:ContentFile){
return {path:x.path,type:x.type}; return {path:x.path,type:x.type};
@ -55,7 +56,7 @@ export const getNotWatched = (diffmgr : DiffManager)=> (ctx:Router.IRouterContex
export function createDiffRouter(diffmgr: DiffManager){ export function createDiffRouter(diffmgr: DiffManager){
const ret = new Router(); const ret = new Router();
ret.get("/list",getAdded(diffmgr)); ret.get("/list",AdminOnlyMiddleware,getAdded(diffmgr));
ret.post("/commit",postAdded(diffmgr)); ret.post("/commit",AdminOnlyMiddleware,postAdded(diffmgr));
return ret; return ret;
} }