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

Use the same hack we did before to initialize the session storage in 2 places

parent 86d9f23c
No related branches found
No related tags found
No related merge requests found
...@@ -83,6 +83,21 @@ func NewTestClient(s globals.Storage, locA, locB string, ndfJSON *ndf.NetworkDef ...@@ -83,6 +83,21 @@ func NewTestClient(s globals.Storage, locA, locB string, ndfJSON *ndf.NetworkDef
return newClient(s, locA, locB, ndfJSON, sendFunc) return newClient(s, locA, locB, ndfJSON, sendFunc)
} }
func (cl *Client) setStorage(locA, password string) error {
// TODO: FIX ME
// While the old session is still valid, we are using the LocA storage to initialize the session
dirname := filepath.Dir(locA)
//FIXME: We need to accept the user's password here!
var err error
io.SessionV2, err = storage.Init(dirname, password)
if err != nil {
return errors.Wrap(err, "Login: could not initialize v2 storage")
}
clientcrypto.SessionV2 = io.SessionV2
cl.sessionV2 = io.SessionV2
return nil
}
// Creates a new Client using the storage mechanism provided. // Creates a new Client using the storage mechanism provided.
// If none is provided, a default storage using OS file access // If none is provided, a default storage using OS file access
// is created // is created
...@@ -110,17 +125,6 @@ func newClient(s globals.Storage, locA, locB string, ndfJSON *ndf.NetworkDefinit ...@@ -110,17 +125,6 @@ func newClient(s globals.Storage, locA, locB string, ndfJSON *ndf.NetworkDefinit
cl.ndf = ndfJSON cl.ndf = ndfJSON
cl.sendFunc = sendFunc cl.sendFunc = sendFunc
// TODO: FIX ME
// While the old session is still valid, we are using the LocA storage to initialize the session
dirname := filepath.Dir(locA)
//FIXME: We need to accept the user's password here!
io.SessionV2, err = storage.Init(dirname, "DUMMYPASSWORDFIXME")
if err != nil {
return nil, errors.Wrap(err, "Login: could not initialize v2 storage")
}
clientcrypto.SessionV2 = io.SessionV2
cl.sessionV2 = io.SessionV2
//Create the cmix group and init the registry //Create the cmix group and init the registry
cmixGrp := cyclic.NewGroup( cmixGrp := cyclic.NewGroup(
large.NewIntFromString(cl.ndf.CMIX.Prime, 16), large.NewIntFromString(cl.ndf.CMIX.Prime, 16),
...@@ -170,6 +174,11 @@ func (cl *Client) Login(password string) (*id.ID, error) { ...@@ -170,6 +174,11 @@ func (cl *Client) Login(password string) (*id.ID, error) {
} }
cl.session = session cl.session = session
locA, _ := cl.storage.GetLocation()
err = cl.setStorage(locA, password)
if err != nil {
return nil, err
}
regState, err := cl.sessionV2.GetRegState() regState, err := cl.sessionV2.GetRegState()
// fixme ! // fixme !
......
...@@ -775,8 +775,6 @@ func TestClient_LogoutAndLoginAgain(t *testing.T) { ...@@ -775,8 +775,6 @@ func TestClient_LogoutAndLoginAgain(t *testing.T) {
t.Fatalf("InitNetwork should have succeeded when creating second client %v", err) t.Fatalf("InitNetwork should have succeeded when creating second client %v", err)
} }
io.SessionV2.SetRegState(user.PermissioningComplete)
_, err = tc.Login("password") _, err = tc.Login("password")
if err != nil { if err != nil {
t.Logf("Login failed %+v", err) t.Logf("Login failed %+v", err)
......
...@@ -314,6 +314,13 @@ func (cl *Client) GenerateKeys(rsaPrivKey *rsa.PrivateKey, ...@@ -314,6 +314,13 @@ func (cl *Client) GenerateKeys(rsaPrivKey *rsa.PrivateKey,
newRm.Comms.Manager = cl.receptionManager.Comms.Manager newRm.Comms.Manager = cl.receptionManager.Comms.Manager
} }
cl.receptionManager = newRm cl.receptionManager = newRm
locA, _ := cl.storage.GetLocation()
err = cl.setStorage(locA, password)
if err != nil {
return err
}
//store the session //store the session
return cl.session.StoreSession() return cl.session.StoreSession()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment