diff --git a/core.go b/core.go index 9345188..2a6ef3b 100644 --- a/core.go +++ b/core.go @@ -189,7 +189,7 @@ func BWLoginGetSessionKey(lc *LoginCredentials) (string, error) { var stdout bytes.Buffer cmd.Stdout = &stdout if err := cmd.Run(); err != nil { - return "", err + return stdout.String(), err } sessionKey := stdout.String() return sessionKey, nil diff --git a/web/controllers/backup_controller.go b/web/controllers/backup_controller.go index 1ea1da1..53f2ced 100644 --- a/web/controllers/backup_controller.go +++ b/web/controllers/backup_controller.go @@ -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 } }