Prevent locking encrypted

Former-commit-id: e986e1b8094f80c479c7f97bdefdcc216ba17ef4 [formerly e4eb6b192ca3af6951acb574d56f2ddd003d6d16] [formerly 142979758915d24210fbc4085270e49611047d59 [formerly fe0c2a45dc56e5b55f5c83f6586f4470a2fa6b1f [formerly 59af266a12]]]
Former-commit-id: f218c28663c6d35b1f9fddb4e618e9cf9f3d12d2 [formerly f665f59e08d5b84845baab64c27fd6a45d3d1dd9]
Former-commit-id: 9877bf4627091886f47a176b88373375e2dbe942
Former-commit-id: 1998538fe1
This commit is contained in:
Zack Scholl 2017-03-22 13:42:51 -06:00
parent 3a463449fb
commit c3ba228288
1 changed files with 13 additions and 4 deletions

View File

@ -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)