Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Rename

Neeraj Gupta1e519280edbf
diff --git a/pkg/account.go b/pkg/account.go
index 666dfa1842..838fc3862e 100644
--- a/pkg/account.go
+++ b/pkg/account.go
@@ -76,7 +76,7 @@ func (c *ClICtrl) storeAccount(_ context.Context, email string, userID int64, ap
if err != nil {
return err
}
- accInfo := model.AccountInfo{
+ accInfo := model.Account{
Email: email,
UserID: userID,
MasterKey: *model.MakeEncString(string(masterKey), secret),
@@ -87,18 +87,18 @@ func (c *ClICtrl) storeAccount(_ context.Context, email string, userID int64, ap
if err != nil {
return err
}
- accountKey := fmt.Sprintf("%s-%d", app, userID)
+ accountKey := accInfo.AccountKey()
return b.Put([]byte(accountKey), accInfoBytes)
})
return err
}
-func (c *ClICtrl) GetAccounts(cxt context.Context) ([]model.AccountInfo, error) {
- var accounts []model.AccountInfo
+func (c *ClICtrl) GetAccounts(cxt context.Context) ([]model.Account, error) {
+ var accounts []model.Account
err := c.DB.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte(AccBucket))
err := b.ForEach(func(k, v []byte) error {
- var info model.AccountInfo
+ var info model.Account
err := json.Unmarshal(v, &info)
if err != nil {
return err
@@ -123,8 +123,8 @@ func (c *ClICtrl) ListAccounts(cxt context.Context) error {
for _, acc := range accounts {
fmt.Println("====================================")
fmt.Println("Email: ", acc.Email)
- fmt.Println("UserID: ", acc.UserID)
- fmt.Println("App: ", acc.App)
+ fmt.Println("ID: ", acc.UserID)
+ fmt.Println("App: ", acc.App)
fmt.Println("====================================")
}
return nil
diff --git a/pkg/model/account.go b/pkg/model/account.go
index 260b5ca4a5..f251a1f502 100644
--- a/pkg/model/account.go
+++ b/pkg/model/account.go
@@ -5,7 +5,7 @@ import (
"fmt"
)
-type AccountInfo struct {
+type Account struct {
Email string `json:"email" binding:"required"`
UserID int64 `json:"userID" binding:"required"`
App api.App `json:"app" binding:"required"`
@@ -13,10 +13,10 @@ type AccountInfo struct {
Token EncString `json:"token" binding:"required"`
}
-func (a AccountInfo) AccountKey() string {
+func (a Account) AccountKey() string {
return fmt.Sprintf("%s-%d", a.App, a.UserID)
}
-func (a AccountInfo) DataBucket() string {
+func (a Account) DataBucket() string {
return fmt.Sprintf("%s-%d-data", a.App, a.UserID)
}