func (s *Session) Login(ctx context.Context, creds apitypes.LoginCredential) error {
	if !creds.Valid() {
		return &apitypes.Error{
			Type: apitypes.BadRequestError,
			Err:  []string{"invalid login credentials provided"},
		}
	}

	var authToken string
	var err error
	switch creds.Type() {
	case apitypes.UserSession:
		authToken, err = attemptHMACLogin(ctx, s.engine.client, s.engine.session, creds)
	case apitypes.MachineSession:
		authToken, err = attemptPDPKALogin(ctx, s.engine.client, s.engine.session, creds)
	}
	if err != nil {
		return err
	}

	self, err := s.engine.client.Self.Get(ctx, authToken)
	if err != nil {
		return err
	}

	s.engine.db.Set(self.Identity)
	if self.Type == apitypes.UserSession {
		s.engine.db.Set(self.Auth)
	}

	return s.engine.session.Set(self.Type, self.Identity, self.Auth, creds.Passphrase(), authToken)
}
// Login attempts to create a valid auth token to authorize http requests made
// against the registry.
Login attempts to create a valid auth token to authorize http requests made
against the registry.
// Login attempts to create a valid auth token to authorize http requests made // against the registry .
func (s *Session) Login(ctx context.Context, creds apitypes.LoginCredential) error {
	if !creds.Valid() {
		return &apitypes.Error{
			Type: apitypes.BadRequestError,
			Err:  []string{"invalid login credentials provided"},
		}
	}
	var authToken string
	var err error
	switch creds.Type() {
	case apitypes.UserSession:
		authToken, err = attemptHMACLogin(ctx, s.engine.client, s.engine.session, creds)
	case apitypes.MachineSession:
		authToken, err = attemptPDPKALogin(ctx, s.engine.client, s.engine.session, creds)
	}
	if err != nil {
		return err
	}
	self, err := s.engine.client.Self.Get(ctx, authToken)
	if err != nil {
		return err
	}
	s.engine.db.Set(self.Identity)
	if self.Type == apitypes.UserSession {
		s.engine.db.Set(self.Auth)
	}
	return s.engine.session.Set(self.Type, self.Identity, self.Auth, creds.Passphrase(), authToken)
}
func ( s * Session ) Login ( ctx context . Context , creds apitypes . LoginCredential ) error { if ! creds . Valid ( ) { return & apitypes . Error { Type : apitypes . BadRequestError , Err : [ ] string { " " } , } } var authToken string var err error switch creds . Type ( ) { case apitypes . UserSession : authToken , err = attemptHMACLogin ( ctx , s . engine . client , s . engine . session , creds ) case apitypes . MachineSession : authToken , err = attemptPDPKALogin ( ctx , s . engine . client , s . engine . session , creds ) } if err != nil { return err } self , err := s . engine . client . Self . Get ( ctx , authToken ) if err != nil { return err } s . engine . db . Set ( self . Identity ) if self . Type == apitypes . UserSession { s . engine . db . Set ( self . Auth ) } return s . engine . session . Set ( self . Type , self . Identity , self . Auth , creds . Passphrase ( ) , authToken ) }
Login attempts to create a valid auth token to authorize http requests made
against the registry.
Login attempts to create a valid auth token to authorize http requests made against the registry .