1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Fix: Bug with decryption

This commit is contained in:
Zack Scholl 2017-03-21 21:10:41 -06:00
parent 5a923ae11a
commit 6012c92c96
2 changed files with 7 additions and 4 deletions

View File

@ -159,16 +159,17 @@ func handleEncrypt(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Wrong password"}) c.JSON(http.StatusOK, gin.H{"success": false, "message": "Wrong password"})
return return
} }
p.IsEncrypted = false
p.Erase() p.Erase()
p = Open(json.Page) p = Open(json.Page)
p.Update(decrypted) p.Update(decrypted)
p.IsEncrypted = false
message = "Decrypted" message = "Decrypted"
} else { } else {
p.IsEncrypted = true currentText := p.Text.GetCurrent()
p.Erase() p.Erase()
p = Open(json.Page) p = Open(json.Page)
encrypted, _ := EncryptString(p.Text.GetCurrent(), json.Passphrase) p.IsEncrypted = true
encrypted, _ := EncryptString(currentText, json.Passphrase)
p.Update(encrypted) p.Update(encrypted)
message = "Encrypted" message = "Encrypted"
} }

View File

@ -162,7 +162,9 @@
}), }),
success: function(data) { success: function(data) {
$('#saveEditButton').text(data.message); $('#saveEditButton').text(data.message);
if (data.success == true) {
window.location = "/{{ .Page }}/view"; window.location = "/{{ .Page }}/view";
}
}, },
error: function(xhr, error) { error: function(xhr, error) {
$('#saveEditButton').text(error); $('#saveEditButton').text(error);