diff --git a/src/client/page/contentinfo.tsx b/src/client/page/contentinfo.tsx index 755a85f..f824a0d 100644 --- a/src/client/page/contentinfo.tsx +++ b/src/client/page/contentinfo.tsx @@ -84,7 +84,7 @@ export const DocumentAbout = (prop: { match: MatchType }) => { -
404 Not Found invalid url : {prop.match.path}
+ 404 Not Found invalid url : {prop.match.path}
); diff --git a/src/client/page/difference.tsx b/src/client/page/difference.tsx index 8257eac..b27a8af 100644 --- a/src/client/page/difference.tsx +++ b/src/client/page/difference.tsx @@ -3,6 +3,7 @@ import { CommonMenuList, Headline } from "../component/mod"; import { UserContext } from "../state"; import { Grid, Paper, Typography } from "@material-ui/core"; + export function DifferencePage(){ const ctx = useContext(UserContext); const [diffList,setDiffList] = useState< @@ -41,11 +42,13 @@ export function DifferencePage(){ } } const menu = CommonMenuList(); - + (ctx.username == "admin") return ( - {diffList.map(x=> + {(ctx.username == "admin") ? (diffList.map(x=> {x.type} - {x.value.map(y=>Commit(y)}>{y.path})} - )} + {x.value.map(y=>(Commit(y)}>{y.path}))} + )):(Not Allowed : please login as an admin) + } + ) } \ No newline at end of file diff --git a/src/diff/router.ts b/src/diff/router.ts index 1992056..b32dee8 100644 --- a/src/diff/router.ts +++ b/src/diff/router.ts @@ -3,6 +3,7 @@ import Router from 'koa-router'; import { ContentFile } from '../content/mod'; import { sendError } from '../route/error_handler'; import {DiffManager} from './diff'; +import {AdminOnlyMiddleware} from '../permission/permission'; function content_file_to_return(x:ContentFile){ return {path:x.path,type:x.type}; @@ -55,7 +56,7 @@ export const getNotWatched = (diffmgr : DiffManager)=> (ctx:Router.IRouterContex export function createDiffRouter(diffmgr: DiffManager){ const ret = new Router(); - ret.get("/list",getAdded(diffmgr)); - ret.post("/commit",postAdded(diffmgr)); + ret.get("/list",AdminOnlyMiddleware,getAdded(diffmgr)); + ret.post("/commit",AdminOnlyMiddleware,postAdded(diffmgr)); return ret; } \ No newline at end of file