OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Allow anonymous users to access public boards
Oliver Günthere9f624f2d9c8
diff --git a/app/views/layouts/_common_head.html.erb b/app/views/layouts/_common_head.html.erbindex c86576a6372..c566c8df547 100644--- a/app/views/layouts/_common_head.html.erb+++ b/app/views/layouts/_common_head.html.erb@@ -12,12 +12,9 @@data-project-id="<%= @project.id %>"data-project-identifier="<%= @project.identifier %>"/><% end %>-<% unless User.current.anonymous? %>- <meta name="current_user"- data-name="<%= User.current.name %>"- data-mail="<%= User.current.mail %>"- data-id="<%= User.current.id %>" />-<% end %>+<meta name="current_user"+ data-name="<%= User.current.name %>"+ data-id="<%= User.current.id %>"/><% if Setting.demo_projects_available %><meta name="demo_projects_available" content="true"/><% end %><% if Setting.boards_demo_data_available %><meta name="boards_demo_data_available" content="true"/><% end %>diff --git a/frontend/src/app/core/current-user/current-user.module.ts b/frontend/src/app/core/current-user/current-user.module.tsindex 7319f93203b..af3471a5e20 100644--- a/frontend/src/app/core/current-user/current-user.module.ts+++ b/frontend/src/app/core/current-user/current-user.module.ts@@ -1,7 +1,4 @@-import {- Injector,- NgModule,-} from '@angular/core';+import { Injector, NgModule } from '@angular/core';import { CurrentUserService } from './current-user.service';import { CurrentUserStore } from './current-user.store';@@ -22,7 +19,6 @@ export function bootstrapModule(injector:Injector):void {currentUserService.setUser({id: userMeta?.dataset.id || null,name: userMeta?.dataset.name || null,- mail: userMeta?.dataset.mail || null,});}diff --git a/frontend/src/app/core/current-user/current-user.query.ts b/frontend/src/app/core/current-user/current-user.query.tsindex f7c348a5788..d24a82674d8 100644--- a/frontend/src/app/core/current-user/current-user.query.ts+++ b/frontend/src/app/core/current-user/current-user.query.ts@@ -1,9 +1,6 @@import { Injectable } from '@angular/core';import { Query } from '@datorama/akita';-import {- CurrentUserState,- CurrentUserStore,-} from './current-user.store';+import { CurrentUserState, CurrentUserStore } from './current-user.store';@Injectable()export class CurrentUserQuery extends Query<CurrentUserState> {@@ -13,5 +10,5 @@ export class CurrentUserQuery extends Query<CurrentUserState> {isLoggedIn$ = this.select((state) => !!state.id);- user$ = this.select(({ id, name, mail }) => ({ id, name, mail }));+ user$ = this.select(({ id, name }) => ({ id, name }));}diff --git a/frontend/src/app/core/current-user/current-user.service.ts b/frontend/src/app/core/current-user/current-user.service.tsindex 0e43fd2dbae..dd51fb1e54a 100644--- a/frontend/src/app/core/current-user/current-user.service.ts+++ b/frontend/src/app/core/current-user/current-user.service.ts@@ -28,20 +28,11 @@import { Injectable } from '@angular/core';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';-import {- CurrentUser,- CurrentUserStore,-} from './current-user.store';+import { CurrentUser, CurrentUserStore } from './current-user.store';import { CurrentUserQuery } from './current-user.query';import { CapabilitiesResourceService } from 'core-app/core/state/capabilities/capabilities.service';import { Observable } from 'rxjs';-import {- distinctUntilChanged,- filter,- map,- switchMap,- take,-} from 'rxjs/operators';+import { distinctUntilChanged, map, switchMap, take } from 'rxjs/operators';import { ApiV3ListFilter } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';import { ICapability } from 'core-app/core/state/capabilities/capability.model';@@ -80,7 +71,7 @@ export class CurrentUserService {.principalFilter$().pipe(map((userFilter) => {- const filters:ApiV3ListFilter[] = [userFilter];+ const filters:ApiV3ListFilter[] = _.compact([userFilter]);if (projectContext) {filters.push(['context', '=', [projectContext === 'global' || projectContext === 'projects' ? 'g' : `p${projectContext}`]]);@@ -133,13 +124,18 @@ export class CurrentUserService {/*** Returns a principal filter for the current user.*/- private principalFilter$():Observable<ApiV3ListFilter> {+ private principalFilter$():Observable<ApiV3ListFilter|null> {return this.user$.pipe(- filter((user) => !!user.id),take(1),- map((user) => ['principal', '=', [user.id as string]]),+ map((user) => {+ if (user.id === null) {+ return null;+ }++ return ['principal', '=', [user.id]];+ }),);}@@ -160,7 +156,6 @@ export class CurrentUserService {private _user:CurrentUser = {id: null,name: null,- mail: null,};/** @deprecated Use the store mechanism `currentUserQuery.user$` */@@ -173,11 +168,6 @@ export class CurrentUserService {return this._user.name || '';}- /** @deprecated Use the store mechanism `currentUserQuery.user$` */- public get mail():string {- return this._user.mail || '';- }-/** @deprecated Use the store mechanism `currentUserQuery.user$` */public get href():string {return `/api/v3/users/${this.userId}`;diff --git a/frontend/src/app/core/current-user/current-user.store.ts b/frontend/src/app/core/current-user/current-user.store.tsindex 1e072312be2..753b5fdd84a 100644--- a/frontend/src/app/core/current-user/current-user.store.ts+++ b/frontend/src/app/core/current-user/current-user.store.ts@@ -27,15 +27,11 @@//++import { Injectable } from '@angular/core';-import {- Store,- StoreConfig,-} from '@datorama/akita';+import { Store, StoreConfig } from '@datorama/akita';export interface CurrentUser {id:string|null;name:string|null;- mail:string|null;}export interface CurrentUserState extends CurrentUser {@@ -45,7 +41,6 @@ export function createInitialState():CurrentUserState {return {id: null,name: null,- mail: null,};}diff --git a/frontend/src/app/features/boards/board/board-list/board-list.component.ts b/frontend/src/app/features/boards/board/board-list/board-list.component.tsindex 2a7916d5684..f16e3fe0d14 100644--- a/frontend/src/app/features/boards/board/board-list/board-list.component.ts+++ b/frontend/src/app/features/boards/board/board-list/board-list.component.ts@@ -15,7 +15,9 @@ import {LoadingIndicatorService,withLoadingIndicator,} from 'core-app/core/loading-indicator/loading-indicator.service';-import { WorkPackageInlineCreateService } from 'core-app/features/work-packages/components/wp-inline-create/wp-inline-create.service';+import {+ WorkPackageInlineCreateService,+} from 'core-app/features/work-packages/components/wp-inline-create/wp-inline-create.service';import { BoardInlineCreateService } from 'core-app/features/boards/board/board-list/board-inline-create.service';import { AbstractWidgetComponent } from 'core-app/shared/components/grids/widgets/abstract-widget.component';import { I18nService } from 'core-app/core/i18n/i18n.service';@@ -23,45 +25,54 @@ import { ToastService } from 'core-app/shared/components/toaster/toast.service';import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/query-space/isolated-query-space';import { Board } from 'core-app/features/boards/board/board';import { AuthorisationService } from 'core-app/core/model-auth/model-auth.service';-import { Highlighting } from 'core-app/features/work-packages/components/wp-fast-table/builders/highlighting/highlighting.functions';-import { WorkPackageCardViewComponent } from 'core-app/features/work-packages/components/wp-card-view/wp-card-view.component';-import { WorkPackageStatesInitializationService } from 'core-app/features/work-packages/components/wp-list/wp-states-initialization.service';+import {+ Highlighting,+} from 'core-app/features/work-packages/components/wp-fast-table/builders/highlighting/highlighting.functions';+import {+ WorkPackageCardViewComponent,+} from 'core-app/features/work-packages/components/wp-card-view/wp-card-view.component';+import {+ WorkPackageStatesInitializationService,+} from 'core-app/features/work-packages/components/wp-list/wp-states-initialization.service';import { BoardService } from 'core-app/features/boards/board/board.service';-import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';+import {+ HalResourceEditingService,+} from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';import { HalResourceNotificationService } from 'core-app/features/hal/services/hal-resource-notification.service';-import { BoardActionsRegistryService } from 'core-app/features/boards/board/board-actions/board-actions-registry.service';+import {+ BoardActionsRegistryService,+} from 'core-app/features/boards/board/board-actions/board-actions-registry.service';import { BoardActionService } from 'core-app/features/boards/board/board-actions/board-action.service';import { ComponentType } from '@angular/cdk/portal';import { CausedUpdatesService } from 'core-app/features/boards/board/caused-updates/caused-updates.service';import { BoardListMenuComponent } from 'core-app/features/boards/board/board-list/board-list-menu.component';import { debugLog } from 'core-app/shared/helpers/debug_output';-import { WorkPackageCardDragAndDropService } from 'core-app/features/work-packages/components/wp-card-view/services/wp-card-drag-and-drop.service';+import {+ WorkPackageCardDragAndDropService,+} from 'core-app/features/work-packages/components/wp-card-view/services/wp-card-drag-and-drop.service';import { BoardFiltersService } from 'core-app/features/boards/board/board-filter/board-filters.service';+import { StateService, TransitionService } from '@uirouter/core';+import {+ WorkPackageViewFocusService,+} from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-focus.service';import {- StateService,- TransitionService,-} from '@uirouter/core';-import { WorkPackageViewFocusService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-focus.service';-import { WorkPackageViewSelectionService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-selection.service';-import { BoardListCrossSelectionService } from 'core-app/features/boards/board/board-list/board-list-cross-selection.service';+ WorkPackageViewSelectionService,+} from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-selection.service';import {- debounceTime,- filter,- map,- take,-} from 'rxjs/operators';+ BoardListCrossSelectionService,+} from 'core-app/features/boards/board/board-list/board-list-cross-selection.service';+import { debounceTime, filter, map } from 'rxjs/operators';import { ChangeItem } from 'core-app/shared/components/fields/changeset/changeset';import { WorkPackageChangeset } from 'core-app/features/work-packages/components/wp-edit/work-package-changeset';import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';import { ApiV3Filter } from 'core-app/shared/helpers/api-v3/api-v3-filter-builder';-import { KeepTabService } from 'core-app/features/work-packages/components/wp-single-view-tabs/keep-tab/keep-tab.service';+import {+ KeepTabService,+} from 'core-app/features/work-packages/components/wp-single-view-tabs/keep-tab/keep-tab.service';import { HalResource } from 'core-app/features/hal/resources/hal-resource';import { QueryResource } from 'core-app/features/hal/resources/query-resource';-import {- HalEvent,- HalEventsService,-} from 'core-app/features/hal/services/hal-events.service';+import { HalEvent, HalEventsService } from 'core-app/features/hal/services/hal-events.service';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import { firstValueFrom } from 'rxjs';import {diff --git a/modules/boards/spec/features/action_boards/status_board_spec.rb b/modules/boards/spec/features/action_boards/status_board_spec.rbindex 6a3b072db89..b1ccb56bd53 100644--- a/modules/boards/spec/features/action_boards/status_board_spec.rb+++ b/modules/boards/spec/features/action_boards/status_board_spec.rb@@ -38,6 +38,9 @@ RSpec.describe 'Status action board', :js, with_ee: %i[board_view] dolet(:type) { create(:type_standard) }let(:project) { create(:project, types: [type], enabled_module_names: %i[work_package_tracking board_view]) }let(:role) { create(:project_role, permissions:) }+ let!(:anon_role) do+ create(:anonymous_role, permissions: %i[view_project view_work_packages view_wiki_pages show_board_views])+ endlet(:board_index) { Pages::BoardIndex.new(project) }@@ -147,7 +150,7 @@ RSpec.describe 'Status action board', :js, with_ee: %i[board_view] doexpect(wp_task.project).to eq(project), 'Moving the card should not change the project'end- it 'allows management of boards' do+ it 'allows management of boards', with_settings: { login_required: false } doboard_index.visit!# Create new board@@ -292,6 +295,14 @@ RSpec.describe 'Status action board', :js, with_ee: %i[board_view] doboard_page.expect_card('Open', 'Task 1', present: false)board_page.expect_card('Closed', 'Task 1', present: true)++ aggregate_failures 'allows to access the board publicly (Regression #51850)' do+ project.update!(public: true)+ login_as User.anonymous++ board_page.visit!+ board_page.expect_card('Closed', 'Task 1', present: true)+ endendit 'shows the default column only once (regression #40858)' dodiff --git a/spec/views/layouts/base.html.erb_spec.rb b/spec/views/layouts/base.html.erb_spec.rbindex 179de56fabe..a4f8bddb5f3 100644--- a/spec/views/layouts/base.html.erb_spec.rb+++ b/spec/views/layouts/base.html.erb_spec.rb@@ -236,8 +236,8 @@ RSpec.describe 'layouts/base' docontext 'with the user being anonymous' dolet(:current_user) { anonymous }- it 'has no current_user metatag' do- expect(rendered).to have_no_css('meta[name=current_user]', visible: false)+ it 'has a current_user metatag' do+ expect(rendered).to have_css('meta[name=current_user]', visible: false)endendend