More buttons
This commit is contained in:
@@ -50,10 +50,16 @@ class SettingsController(
|
||||
}
|
||||
|
||||
fun export(request: Request, jwtPayload: JwtPayload): Response {
|
||||
val isDownload = request.form("download") != null
|
||||
val json = userService.export(jwtPayload.userId)
|
||||
return Response(Status.OK).body(json).header("Content-Type", "application/json")
|
||||
val res = Response(Status.OK).body(json).header("Content-Type", "application/json")
|
||||
return if (isDownload) res.header("Content-Disposition",
|
||||
"attachment; filename=\"simplenotes-export-${sanitizeFilename(jwtPayload.username)}.json\"")
|
||||
else res
|
||||
}
|
||||
|
||||
private fun sanitizeFilename(inputName: String): String = inputName.replace("[^a-zA-Z0-9-_.]".toRegex(), "_")
|
||||
|
||||
private fun Request.deleteForm(jwtPayload: JwtPayload) =
|
||||
DeleteForm(jwtPayload.username, form("password"), form("checked") != null)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user