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"})
|
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"
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,9 @@
|
|||||||
}),
|
}),
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
$('#saveEditButton').text(data.message);
|
$('#saveEditButton').text(data.message);
|
||||||
window.location = "/{{ .Page }}/view";
|
if (data.success == true) {
|
||||||
|
window.location = "/{{ .Page }}/view";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, error) {
|
error: function(xhr, error) {
|
||||||
$('#saveEditButton').text(error);
|
$('#saveEditButton').text(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user