From 59af266a124a8f1497772830fa7543b09bfac5db Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Wed, 22 Mar 2017 13:42:51 -0600 Subject: [PATCH] Prevent locking encrypted --- handlers.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/handlers.go b/handlers.go index 142c5fe..5adffaa 100755 --- a/handlers.go +++ b/handlers.go @@ -75,10 +75,15 @@ func handlePageRequest(c *gin.Context) { p.Update("*This page has now self-destructed.*\n\n" + p.Text.GetCurrent()) p.Erase() } - if command == "/erase" && !p.IsLocked && !p.IsEncrypted { - p.Erase() - c.Redirect(302, "/"+page+"/edit") - return + if command == "/erase" { + if !p.IsLocked && !p.IsEncrypted { + p.Erase() + c.Redirect(302, "/"+page+"/edit") + return + } else { + c.Redirect(302, "/"+page+"/view") + return + } } rawText := p.Text.GetCurrent() rawHTML := p.RenderedPage @@ -189,6 +194,10 @@ func handleLock(c *gin.Context) { return } p := Open(json.Page) + if p.IsEncrypted { + c.JSON(http.StatusOK, gin.H{"success": false, "message": "Encrypted"}) + return + } var message string if p.IsLocked { err2 := CheckPasswordHash(json.Passphrase, p.PassphraseToUnlock)