mirror of
https://github.com/balzack/databag.git
synced 2025-04-20 16:45:25 +00:00
adding clear seal endpoint
This commit is contained in:
parent
d6e08ef44a
commit
d8480f86f6
44
net/server/internal/api_clearAccountSeal.go
Normal file
44
net/server/internal/api_clearAccountSeal.go
Normal file
@ -0,0 +1,44 @@
|
||||
package databag
|
||||
|
||||
import (
|
||||
"databag/internal/store"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//ClearAccountSeal sets sealing key for channels
|
||||
func ClearAccountSeal(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
account, code, err := ParamAgentToken(r, true)
|
||||
if err != nil {
|
||||
ErrResponse(w, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
// update record
|
||||
account.AccountDetail.SealSalt = ""
|
||||
account.AccountDetail.SealIV = ""
|
||||
account.AccountDetail.SealPrivate = ""
|
||||
account.AccountDetail.SealPublic = ""
|
||||
|
||||
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
||||
if res := tx.Save(&account.AccountDetail).Error; res != nil {
|
||||
return res
|
||||
}
|
||||
if res := tx.Model(&account).Update("profile_revision", account.ProfileRevision+1).Error; res != nil {
|
||||
return res
|
||||
}
|
||||
if res := tx.Model(&account).Update("account_revision", account.AccountRevision+1).Error; res != nil {
|
||||
return res
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
ErrResponse(w, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
SetProfileNotification(account)
|
||||
SetStatus(account)
|
||||
WriteResponse(w, nil)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user