Skip to content
Snippets Groups Projects
Commit 9851c12a authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Fix init subcommand

parent cd002173
No related branches found
No related tags found
3 merge requests!510Release,!226WIP: Api2.0,!207WIP: Client Restructure
...@@ -29,7 +29,7 @@ func Login(client *api.Client, callbacks auth.Callbacks) (m *Client, err error) ...@@ -29,7 +29,7 @@ func Login(client *api.Client, callbacks auth.Callbacks) (m *Client, err error)
backup: &Container{}, backup: &Container{},
} }
m.e2e, err = loadOrInitE2e(client) m.e2e, err = LoadOrInitE2e(client)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -44,10 +44,10 @@ func Login(client *api.Client, callbacks auth.Callbacks) (m *Client, err error) ...@@ -44,10 +44,10 @@ func Login(client *api.Client, callbacks auth.Callbacks) (m *Client, err error)
return m, err return m, err
} }
// loadOrInitE2e loads the e2e handler or makes a new one, generating a new // LoadOrInitE2e loads the e2e handler or makes a new one, generating a new
// e2e private key. It attempts to load via a legacy construction, then tries // e2e private key. It attempts to load via a legacy construction, then tries
// to load the modern one, creating a new modern ID if neither can be found // to load the modern one, creating a new modern ID if neither can be found
func loadOrInitE2e(client *api.Client) (e2e.Handler, error) { func LoadOrInitE2e(client *api.Client) (e2e.Handler, error) {
usr := client.GetUser() usr := client.GetUser()
e2eGrp := client.GetStorage().GetE2EGroup() e2eGrp := client.GetStorage().GetE2EGroup()
kv := client.GetStorage().GetKV() kv := client.GetStorage().GetKV()
......
...@@ -10,9 +10,11 @@ package cmd ...@@ -10,9 +10,11 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper" "github.com/spf13/viper"
"gitlab.com/elixxir/client/api/messenger"
) )
// initCmd creates a new user object with the given NDF // initCmd creates a new user object with the given NDF
...@@ -22,7 +24,13 @@ var initCmd = &cobra.Command{ ...@@ -22,7 +24,13 @@ var initCmd = &cobra.Command{
Args: cobra.NoArgs, Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
client := createClient() client := createClient()
e2e, err := messenger.LoadOrInitE2e(client)
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
user := client.GetUser() user := client.GetUser()
user.E2eDhPublicKey = e2e.GetHistoricalDHPubkey()
jww.INFO.Printf("User: %s", user.ReceptionID) jww.INFO.Printf("User: %s", user.ReceptionID)
writeContact(user.GetContact()) writeContact(user.GetContact())
fmt.Printf("%s\n", user.ReceptionID) fmt.Printf("%s\n", user.ReceptionID)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment