diff --git a/bindata.go.REMOVED.git-id b/bindata.go.REMOVED.git-id index bf5f6b2..21d3f15 100644 --- a/bindata.go.REMOVED.git-id +++ b/bindata.go.REMOVED.git-id @@ -1 +1 @@ -c19fe3dc9ffad04d7007790f9903978aa803d05c \ No newline at end of file +083d9060ba97213d049e1f19f11ff57620b5956e \ No newline at end of file diff --git a/handlers.go b/handlers.go index eaf2111..e980bcf 100755 --- a/handlers.go +++ b/handlers.go @@ -73,6 +73,14 @@ func handlePageRequest(c *gin.Context) { version := c.DefaultQuery("version", "ajksldfjl") p := Open(page) + + // Disallow anything but viewing locked/encrypted pages + if (p.IsEncrypted || p.IsLocked) && command[0:2] != "/v" { + c.Redirect(302, "/"+page+"/view") + return + } + + // Destroy page if it is opened and primed if p.IsPrimedForSelfDestruct && !p.IsLocked && !p.IsEncrypted { p.Update("*This page has now self-destructed.*\n\n" + p.Text.GetCurrent()) p.Erase() diff --git a/templates/index.tmpl b/templates/index.tmpl index d5d289c..1568bc2 100755 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -193,11 +193,12 @@ $('#saveEditButton').addClass("failure"); } $('#saveEditButton').text(data.message); - if ($('#lockPage').val() == "Lock") { - $('#lockPage').text("Unlock"); - } else { - $('#lockPage').text("Lock"); - } + if (data.success == true && $('#lockPage').text() == "Lock") { + window.location = "/{{ .Page }}/view"; + } + if (data.success == true && $('#lockPage').text() == "Unlock") { + window.location = "/{{ .Page }}/edit"; + } }, error: function(xhr, error) { $('#saveEditButton').removeClass() @@ -218,10 +219,19 @@ passphrase: passphrase }), success: function(data) { - $('#saveEditButton').text(data.message); - if (data.success == true) { - window.location = "/{{ .Page }}/view"; + $('#saveEditButton').removeClass() + if (data.success == true) { + $('#saveEditButton').addClass("success"); + } else { + $('#saveEditButton').addClass("failure"); } + $('#saveEditButton').text(data.message); + if (data.success == true && $('#encryptPage').text() == "Encrypt") { + window.location = "/{{ .Page }}/view"; + } + if (data.success == true && $('#encryptPage').text() == "Decrypt") { + window.location = "/{{ .Page }}/edit"; + } }, error: function(xhr, error) { $('#saveEditButton').text(error); @@ -329,17 +339,32 @@