implemented delivery of user files
This commit is contained in:
@@ -131,7 +131,25 @@ public class FileModule extends BaseHandler implements FileService {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getUserFiles(Path path, HttpExchange ex, UmbrellaUser user) {
|
private boolean getUserFiles(Path path, HttpExchange ex, UmbrellaUser user) throws IOException {
|
||||||
return false;
|
var userId = path.pop();
|
||||||
|
if (userId == null) throw missingFieldException(USER_ID);
|
||||||
|
long uid;
|
||||||
|
try {
|
||||||
|
uid = Long.parseLong(userId);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw invalidFieldException(PROJECT_ID,"Long");
|
||||||
|
}
|
||||||
|
var filename = "/user/"+uid;
|
||||||
|
if (!path.empty()) filename += "/"+URLDecoder.decode(path.toString(),UTF_8);
|
||||||
|
if (uid != user.id() && !fileDb.isPermitted(user,filename)) throw forbidden("You are not allowed to access {0}",filename);
|
||||||
|
var file = new File(baseDir+filename);
|
||||||
|
if (!file.exists()) throw unprocessable("{0} does not exist!",filename);
|
||||||
|
if (file.isDirectory()){
|
||||||
|
Map<String,Object> map = getDirectory(file);
|
||||||
|
map.put("title",filename);
|
||||||
|
return sendContent(ex,map);
|
||||||
|
}
|
||||||
|
return getFile(ex, file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,12 @@
|
|||||||
</Router>
|
</Router>
|
||||||
{:else}
|
{:else}
|
||||||
<Router>
|
<Router>
|
||||||
|
{#if messages.error}
|
||||||
|
<span class="error">{@html messages.error}</span>
|
||||||
|
{/if}
|
||||||
|
{#if messages.warning}
|
||||||
|
<span class="error">{@html messages.warning}</span>
|
||||||
|
{/if}
|
||||||
<Route path="/user/reset/pw" component={ResetPw} />
|
<Route path="/user/reset/pw" component={ResetPw} />
|
||||||
<Route path="/oidc_callback" component={Callback} />
|
<Route path="/oidc_callback" component={Callback} />
|
||||||
<Route path="/wiki/:key/view" component={WikiGuest} />
|
<Route path="/wiki/:key/view" component={WikiGuest} />
|
||||||
|
|||||||
Reference in New Issue
Block a user