mirror of
https://github.com/vwxyzjn/portwarden
synced 2025-12-20 09:33:14 +00:00
API-1 # Use POST request to backup portwarden files
This commit is contained in:
34
web/controllers/backup_controller.go
Normal file
34
web/controllers/backup_controller.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/vwxyzjn/portwarden"
|
||||
"github.com/vwxyzjn/portwarden/web/models"
|
||||
)
|
||||
|
||||
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()})
|
||||
return
|
||||
}
|
||||
|
||||
spew.Dump(&bi.BitwardenLoginCredentials)
|
||||
sessionKey, err := portwarden.BWLoginGetSessionKey(&bi.BitwardenLoginCredentials)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
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()})
|
||||
return
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user