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:
parent
5a923ae11a
commit
6012c92c96
7
main.go
7
main.go
@ -159,16 +159,17 @@ func handleEncrypt(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Wrong password"})
|
||||
return
|
||||
}
|
||||
p.IsEncrypted = false
|
||||
p.Erase()
|
||||
p = Open(json.Page)
|
||||
p.Update(decrypted)
|
||||
p.IsEncrypted = false
|
||||
message = "Decrypted"
|
||||
} else {
|
||||
p.IsEncrypted = true
|
||||
currentText := p.Text.GetCurrent()
|
||||
p.Erase()
|
||||
p = Open(json.Page)
|
||||
encrypted, _ := EncryptString(p.Text.GetCurrent(), json.Passphrase)
|
||||
p.IsEncrypted = true
|
||||
encrypted, _ := EncryptString(currentText, json.Passphrase)
|
||||
p.Update(encrypted)
|
||||
message = "Encrypted"
|
||||
}
|
||||
|
@ -162,7 +162,9 @@
|
||||
}),
|
||||
success: function(data) {
|
||||
$('#saveEditButton').text(data.message);
|
||||
window.location = "/{{ .Page }}/view";
|
||||
if (data.success == true) {
|
||||
window.location = "/{{ .Page }}/view";
|
||||
}
|
||||
},
|
||||
error: function(xhr, error) {
|
||||
$('#saveEditButton').text(error);
|
||||
|
Loading…
Reference in New Issue
Block a user