1
0
mirror of https://github.com/vwxyzjn/portwarden synced 2025-12-18 00:33:13 +00:00

API-1 # Return basic error messages to the front end

This commit is contained in:
Costa Huang
2018-11-16 17:45:24 -05:00
parent 368f2c7ef7
commit c30f1ed31b
2 changed files with 4 additions and 5 deletions

View File

@@ -14,21 +14,20 @@ import (
func EncryptBackupController(c *gin.Context) {
var bi models.BackupInfo
if err := c.ShouldBindJSON(&bi); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error(), "message": ""})
return
}
spew.Dump(&bi.BitwardenLoginCredentials)
sessionKey, err := portwarden.BWLoginGetSessionKey(&bi.BitwardenLoginCredentials)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error(), "message": sessionKey})
return
}
fmt.Println(sessionKey)
err = portwarden.CreateBackupFile(bi.FileNamePrefix, bi.Passphrase, sessionKey, models.BackupDefaultSleepMilliseconds)
if err != nil {
panic(err)
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error(), "message": sessionKey})
return
}
}