public override void Handle(FlowEvent @event, FlowContext context) { if (@event.Equals(FlowEvent.UserHasNoRoleInOrganization)) { _organizationRoleService.MakeUser(_user, _ssoOrganization); context.TransitionTo(_ssoStateFactory.CreateUserLoggedIn(_user), _ => _.HandleRoleAssigned()); } }
public override void Handle(FlowEvent @event, FlowContext context) { if (@event.Equals(FlowEvent.UserPrivilegeVerified)) { var userResult = _ssoUserIdentityRepository.GetByExternalUuid(_userUuid); if (userResult.HasValue) // User has used the same SSO identity before and exists { var user = userResult.Value.User; if (user.CanAuthenticate()) { context.TransitionTo(_ssoStateFactory.CreateUserLoggedIn(user), _ => _.HandleUserSeenBefore()); } else { var stsBrugerInfo = _stsBrugerInfoService.GetStsBrugerInfo(_userUuid, _cvrNumber); if (!stsBrugerInfo.HasValue) { context.TransitionTo(_ssoStateFactory.CreateErrorState(), _ => _.HandleUnableToResolveUserInStsOrganisation()); } else { context.TransitionTo(_ssoStateFactory.CreateUserIdentifiedState(user, stsBrugerInfo.Value), _ => _.HandleExistingSsoUserWithoutRoles()); } } } else // Try to find the user by email { var stsBrugerInfo = _stsBrugerInfoService.GetStsBrugerInfo(_userUuid, _cvrNumber); if (!stsBrugerInfo.HasValue) { context.TransitionTo(_ssoStateFactory.CreateErrorState(), _ => _.HandleUnableToResolveUserInStsOrganisation()); } else { var userByKitosEmail = FindUserByEmail(stsBrugerInfo); if (userByKitosEmail.HasValue) { context.TransitionTo(_ssoStateFactory.CreateUserIdentifiedState(userByKitosEmail.Value, stsBrugerInfo.Value), _ => _.HandleUserFirstTimeSsoVisit()); } else { context.TransitionTo(_ssoStateFactory.CreateFirstTimeUserNotFoundState(stsBrugerInfo.Value), _ => _.HandleUnableToLocateUser()); } } } } }
public override void Handle(FlowEvent @event, FlowContext context) { if (@event.Equals(FlowEvent.OrganizationNotFound)) { if (_user.CanAuthenticate()) { context.TransitionTo(_stateFactory.CreateUserLoggedIn(_user), _ => _.HandleUserHasRoleInOrganization()); } else { context.TransitionTo(_stateFactory.CreateErrorState(), _ => _.HandleNoRoleAndOrganization()); } } }
public override void Handle(FlowEvent @event, FlowContext context) { if (@event.Equals(FlowEvent.OrganizationFound)) { var rolesInOrganization = _organizationRoleService.GetRolesInOrganization(_user, _ssoOrganization.Id); if (rolesInOrganization.Any()) { context.TransitionTo(_ssoStateFactory.CreateUserLoggedIn(_user), _ => _.HandleUserHasRoleInOrganization()); } else { context.TransitionTo(_ssoStateFactory.CreateAssigningRoleState(_user, _ssoOrganization), _ => _.HandleUserHasNoRoleInOrganization()); } } }