Various fixes

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-02-11 12:45:06 +04:00
parent d8bb4040a1
commit e0bb27bff4
6 changed files with 17 additions and 15 deletions

View File

@@ -321,11 +321,12 @@ func (s SessionService) OpenPasswordChildSessionForOrganization(
organizationID gid.GID,
) (*coredata.Session, *coredata.Membership, error) {
var (
now = time.Now()
rootSession = &coredata.Session{}
identity = &coredata.Identity{}
membership = &coredata.Membership{}
scope = coredata.NewScopeFromObjectID(organizationID)
now = time.Now()
rootSession = &coredata.Session{}
identity = &coredata.Identity{}
membership = &coredata.Membership{}
childSession = &coredata.Session{}
scope = coredata.NewScopeFromObjectID(organizationID)
)
err := s.pg.WithTx(
@@ -365,7 +366,7 @@ func (s SessionService) OpenPasswordChildSessionForOrganization(
}
tenantID := scope.GetTenantID()
childSession := &coredata.Session{
childSession = &coredata.Session{
ID: gid.New(tenantID, coredata.SessionEntityType),
IdentityID: rootSession.IdentityID,
TenantID: &tenantID,
@@ -398,7 +399,7 @@ func (s SessionService) OpenPasswordChildSessionForOrganization(
return nil, nil, err
}
return rootSession, membership, nil
return childSession, membership, nil
}
// OpenSAMLChildSessionForOrganization creates a SAML-authenticated child session for the given
@@ -535,7 +536,7 @@ func (s SessionService) AssumeOrganizationSession(
}
// If child session already exists use it
if err := childSession.LoadByRootSessionIDAndMembershipID(ctx, tx, rootSession.IdentityID, membership.ID); err == nil {
if err := childSession.LoadByRootSessionIDAndMembershipID(ctx, tx, rootSession.ID, membership.ID); err == nil {
if childSession.ExpireReason == nil && now.Before(childSession.ExpiredAt) {
return nil
}

View File

@@ -408,13 +408,13 @@ func (r *mutationResolver) SignIn(ctx context.Context, input types.SignInInput)
if input.OrganizationID != nil {
var err error
session, _, err = r.iam.SessionService.OpenPasswordChildSessionForOrganization(ctx, session.ID, *input.OrganizationID)
_, _, err = r.iam.SessionService.OpenPasswordChildSessionForOrganization(ctx, session.ID, *input.OrganizationID)
if err != nil {
// Here session middleware already took care of expired/nil root session so we only handle membership related errors
var errMembershipNotFound *iam.ErrMembershipNotFound
var errMembershipInactive *iam.ErrMembershipInactive
if errors.As(err, errMembershipNotFound) || errors.As(err, errMembershipInactive) {
if errors.As(err, &errMembershipNotFound) || errors.As(err, &errMembershipInactive) {
return nil, gqlutils.Forbidden(ctx, err)
}