@tech4good/angular-schematics 21.4.0 → 21.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/package.json +1 -1
  3. package/src/ng-add/files/.firebaserc.template +2 -1
  4. package/src/ng-add/files/bigquery/queries/active_time_by_route.sql.template +34 -0
  5. package/src/ng-add/files/bigquery/scripts/export_entities.py.template +143 -0
  6. package/src/ng-add/files/bigquery/scripts/run_query.py.template +167 -0
  7. package/src/ng-add/files/bigquery/views/events_flat.sql.template +60 -0
  8. package/src/ng-add/files/bigquery/views/logs_latest.sql.template +34 -0
  9. package/src/ng-add/files/docs-infra/analytics-guide.md.template +170 -0
  10. package/src/ng-add/files/firebase.logs.json.template +5 -0
  11. package/src/ng-add/files/firestore.indexes.json.template +89 -0
  12. package/src/ng-add/files/firestore.logs.rules.spec.ts.template +100 -0
  13. package/src/ng-add/files/firestore.logs.rules.template +8 -0
  14. package/src/ng-add/files/jest.config.ts.template +1 -1
  15. package/src/ng-add/files/package.json.template +4 -3
  16. package/src/ng-add/files/src/app/core/analytics/log.service.ts.template +26 -4
  17. package/src/ng-add/files/src/app/core/analytics/time-analytics.service.spec.ts.template +145 -2
  18. package/src/ng-add/files/src/app/core/analytics/time-analytics.service.ts.template +355 -149
  19. package/src/ng-add/files/src/app/core/auth/guards/require-auth-and-consent.guard.ts.template +3 -1
  20. package/src/ng-add/files/src/app/first-time/consent/consent.component.html.template +172 -48
  21. package/src/ng-add/files/src/app/first-time/consent/consent.component.scss.template +31 -0
  22. package/src/ng-add/files/src/app/first-time/consent/consent.component.spec.ts.template +31 -3
  23. package/src/ng-add/files/src/app/first-time/consent/consent.component.ts.template +12 -11
  24. package/src/ng-add/files/src/app/first-time/consent/consent.guard.ts.template +0 -6
  25. package/src/ng-add/files/src/app/first-time/early-access/early-access.guard.ts.template +7 -1
  26. package/src/ng-add/files/src/app/first-time/first-time-routing.spec.ts.template +7 -6
@@ -1,57 +1,181 @@
1
1
  <app-navbar></app-navbar>
2
2
  <main class="consent-container">
3
- <h1>Research Consent and Privacy Policy</h1>
3
+ <h1>Terms of Service, Privacy Policy, and Research Consent</h1>
4
4
  <div class="separator"></div>
5
5
 
6
- <p>{{ appName }} is a platform that {{ shortProdDesc }}. It is also an experimental platform run by the <a href="https://tech4good.soe.ucsc.edu" target="_blank">Tech4Good Lab</a> for studying {{ shortResearchDesc }}.</p>
7
-
8
- <p>This Research Consent and Privacy Policy describes how and when {{ appName }} collects, uses and shares your information when you use our Services. {{ appName }} receives your information through our website and from our partners and other third parties for the purpose of delivering services, improving them, and conducting research. For example, you send us information when you sign into {{ appName }} with {{ authAppName }}. When using any of our Services you consent to the collection, transfer, manipulation, storage, disclosure and other uses of your information as described in this Research Consent and Privacy Policy.</p>
9
-
10
- <p>This Research Consent and Privacy Policy also describes the research studies you will be participating in, IRB approved under UCSC Study {{ protocolNumber }} titled "{{ protocolTitle }}".</p>
11
-
12
- <h2>Research Study Information</h2>
6
+ <p>
7
+ {{ appName }} is a platform that {{ shortProdDesc }}. It is also an experimental platform run by
8
+ {{ organizationName }} for studying {{ shortResearchDesc }}.
9
+ </p>
10
+
11
+ <p>
12
+ This document outlines the Terms of Service, Privacy Policy, and Research Consent for using
13
+ {{ appName }}. {{ appName }} receives your information through our website and from our partners
14
+ and other third parties for the purpose of delivering services, improving them, and conducting
15
+ research. For example, you send us information when you sign into {{ appName }} with {{ authAppName }}.
16
+ By using any of our Services, you agree to the collection, transfer, manipulation, storage,
17
+ disclosure, and other uses of your information as described in this document.
18
+ </p>
19
+
20
+ <h2>1. Terms of Service</h2>
21
+
22
+ <p class="substep">
23
+ <b>Acceptable Use</b>: You agree to use {{ appName }} solely for lawful educational, learning,
24
+ and platform interaction purposes. You agree not to reverse engineer, disrupt, tamper with, or
25
+ gain unauthorized access to any platform systems, servers, or user accounts.
26
+ </p>
27
+
28
+ <p class="substep">
29
+ <b>Disclaimer of Warranties</b>: {{ appName }} is provided on an "AS IS" and "AS AVAILABLE" basis.
30
+ While we strive for high service quality, {{ organizationName }} and its contributors make no express
31
+ or implied warranties regarding platform uptime, error-free operation, or specific learning
32
+ outcomes.
33
+ </p>
34
+
35
+ <p class="substep">
36
+ <b>Limitation of Liability</b>: To the maximum extent permitted by applicable law, {{ organizationName }}
37
+ and its creators, maintainers, or partners shall not be liable for any direct, indirect, incidental,
38
+ or consequential damages arising from your use of or inability to use the platform.
39
+ </p>
40
+
41
+ <p class="substep">
42
+ <b>Intellectual Property and Content</b>: All platform code, branding, graphics, and instructional
43
+ materials are owned by or licensed to {{ organizationName }}. User contributions and feedback are used
44
+ to operate and improve the platform and associated research projects.
45
+ </p>
46
+
47
+ <p class="substep">
48
+ <b>Account Termination</b>: We reserve the right to suspend or terminate user accounts that
49
+ violate these Terms of Service or engage in abusive, security-impacting, or unauthorized behavior.
50
+ </p>
51
+
52
+ <h2>2. Privacy Policy</h2>
53
+
54
+ <p class="substep">
55
+ <b>Basic Account Information</b>: When you create or reconfigure a {{ appName }} account, you
56
+ provide some personal information, such as your name and email address.
57
+ </p>
58
+
59
+ <p class="substep">
60
+ <b>Additional Information</b>: We may use your email address to send you notifications for the
61
+ projects you are participating in. If we do, you will be able to unsubscribe through your
62
+ account settings or by following the instructions contained within email notifications. If you
63
+ email us, we may keep your message, email address and contact information to respond to your
64
+ request. If you connect your {{ appName }} account to your account on another service, the other
65
+ service may send us your registration or profile information on that service and other
66
+ information that you authorize. Providing the additional information described in this section
67
+ is entirely optional.
68
+ </p>
69
+
70
+ <p class="substep">
71
+ <b>Service Usage Data</b>: Our Services are primarily designed to {{ usageDataProductDesc }}.
72
+ </p>
73
+
74
+ <p class="substep">
75
+ <b>Cookies & Analytics</b>: Like many websites, we use cookies and similar technologies to collect
76
+ additional website usage data to improve our Services and to conduct research to learn
77
+ {{ usageDataResearchDesc }}. A cookie is a small data file that is transferred to your
78
+ computer's hard disk. {{ appName }} may use both session cookies and persistent cookies to
79
+ better understand how you interact with our Services, to monitor aggregate usage by our users
80
+ and web traffic routing on our Services, and to customize and improve our Services. Most
81
+ Internet browsers automatically accept cookies. You can instruct your browser, by changing its
82
+ settings, to stop accepting cookies or to prompt you before accepting a cookie from the websites
83
+ you visit. However, some Services may not function properly if you disable cookies.
84
+ </p>
85
+
86
+ <p class="substep">
87
+ <b>Third-Party Sub-processors</b>: We do not sell, trade, or rent your personal information.
88
+ We share data only with trusted infrastructure and service providers (such as Google Cloud / Firebase
89
+ for hosting, database storage, and authentication) that assist us in operating the platform, subject
90
+ to strict confidentiality agreements.
91
+ </p>
92
+
93
+ <p class="substep">
94
+ <b>Data Retention & Erasure</b>: We retain your account data for as long as your account remains active.
95
+ You have the right to access, modify, or request deletion of your personal information at any time.
96
+ Upon receiving an account or data deletion request, we will delete or anonymize your personal data
97
+ within 30 days.
98
+ </p>
99
+
100
+ <p class="substep">
101
+ <b>Law and Harm</b>: Notwithstanding anything to the contrary in this Policy, we may preserve or
102
+ disclose your information if we believe that it is reasonably necessary to comply with a law,
103
+ regulation or legal request; to protect the safety of any person; to address fraud, security or
104
+ technical issues; or to protect {{ appName }}'s rights or property.
105
+ </p>
106
+
107
+ <h2>3. Research Study Information</h2>
108
+
109
+ <p>
110
+ This platform also incorporates research studies approved under UCSC IRB Study
111
+ {{ protocolNumber }} titled "{{ protocolTitle }}".
112
+ </p>
13
113
 
14
114
  <p class="substep"><b>What will you do in the study</b>: {{ studyDoingDesc }}.</p>
15
-
16
- <p class="substep"><b>Risks or discomforts</b>: While researchers follow procedures to maintain your confidentiality, as with any internet activity, we cannot guarantee confidentiality of interception of data sent via the Internet by any third parties, so there is a risk that your information could be accidentally disclosed. However, we do not see foreseeable risks even if information is accidentally disclosed.</p>
17
-
18
- <p class="substep"><b>Benefits and costs</b>: There are no costs to you for participation. You may benefit by using the platform {{ benefitsDesc }}, but we do not guarantee that any benefits will occur.</p>
19
-
20
- <p class="substep"><b>Voluntary participation</b>: All participation is voluntary and you may choose to discontinue use of the platform at any time.</p>
21
-
22
- <p class="substep"><b>Rights and concerns</b>: If you have questions about this research study, please contact {{ investigatorInfo }} or the faculty member supervising this research {{ facultyInfo }}. If you have any questions regarding your rights as a research participant, please contact the University of California Santa Cruz, Office of Research Compliance Administration at 831-459-1473 or orca&#64;ucsc.edu.</p>
23
-
24
- <h2>Information Collection and Use</h2>
25
-
26
- <p class="substep"><b>Basic Account Information</b>: When you create or reconfigure a {{ appName }} account, you provide some personal information, such as your name and email address.</p>
27
-
28
- <p class="substep"><b>Additional Information</b>: We may use your email address to send you notifications for the projects you are participating in. If we do, you will be able to unsubscribe through your account settings or by following the instructions contained within email notifications. If you email us, we may keep your message, email address and contact information to respond to your request. If you connect your {{ appName }} account to your account on another service, the other service may send us your registration or profile information on that service and other information that you authorize. Providing the additional information described in this section is entirely optional.</p>
29
-
30
- <p class="substep"><b>Service Usage Data</b>: Our Services are primarily designed to {{ usageDataProductDesc }}.</p>
31
-
32
- <p class="substep"><b>Cookies</b>: Like many websites, we use cookies and similar technologies to collect additional website usage data to improve our Services and to conduct research to learn {{ usageDataResearchDesc }}. A cookie is a small data file that is transferred to your computer's hard disk. {{ appName }} may use both session cookies and persistent cookies to better understand how you interact with our Services, to monitor aggregate usage by our users and web traffic routing on our Services, and to customize and improve our Services. Most Internet browsers automatically accept cookies. You can instruct your browser, by changing its settings, to stop accepting cookies or to prompt you before accepting a cookie from the websites you visit. However, some Services may not function properly if you disable cookies.</p>
33
-
34
- <h2>Information Sharing and Disclosure</h2>
35
-
36
- <p class="substep"><b>Transfer of information</b>: We do not sell, trade, or otherwise transfer to outside parties your personally identifiable information. This does not include trusted third parties who assist us in operating our website, conducting research, or servicing you, so long as those parties agree to keep this information confidential. Additionally, parties given access to research data will also be IRB approved.</p>
37
-
38
- <p class="substep"><b>Law and Harm</b>: Notwithstanding anything to the contrary in this Policy, we may preserve or disclose your information if we believe that it is reasonably necessary to comply with a law, regulation or legal request; to protect the safety of any person; to address fraud, security or technical issues; or to protect {{ appName }}'s rights or property. However, nothing in this Privacy Policy is intended to limit any legal defenses or objections that you may have to a third party’s, including a government’s, request to disclose your information.</p>
39
-
40
- <h2>Modifying Your Personal Information</h2>
41
-
42
- <p>If you are a registered user of our Services, we provide you with tools and account settings to access or modify the personal information you provided to us and associated with your account.</p>
43
-
44
- <h2>Changes to This Policy</h2>
45
-
46
- <p>We may revise this Privacy Policy from time to time. The most current version of the policy will govern our use of your information and will be at <a routerLink="/consent">{{ consentUrl }}</a>. If we make a change to this policy that, in our sole discretion, is material, we will notify you via an email to the email address associated with your account. By continuing to access or use the Services after those changes become effective, you agree to be bound by the revised Privacy Policy.</p>
47
115
 
48
- <form [formRoot]="consentForm">
49
- <div class="agree-container">
50
- <mat-checkbox [color]="'primary'" [formField]="consentForm.checked"><span style="white-space:normal;" class="permission-text">I have read and understood the above, agree to the terms of use, and consent to participate in the research study.</span></mat-checkbox>
116
+ <p class="substep">
117
+ <b>Risks or discomforts</b>: While researchers follow procedures to maintain your
118
+ confidentiality, as with any internet activity, we cannot guarantee confidentiality of
119
+ interception of data sent via the Internet by any third parties, so there is a risk that your
120
+ information could be accidentally disclosed. However, we do not see foreseeable risks even if
121
+ information is accidentally disclosed.
122
+ </p>
123
+
124
+ <p class="substep">
125
+ <b>Benefits and costs</b>: There are no costs to you for participation. You may benefit by using
126
+ the platform {{ benefitsDesc }}, but we do not guarantee that any benefits will occur.
127
+ </p>
128
+
129
+ <p class="substep">
130
+ <b>Voluntary participation</b>: All research participation is voluntary and you may choose to
131
+ discontinue use of the platform at any time.
132
+ </p>
133
+
134
+ <p class="substep">
135
+ <b>Rights and concerns</b>: If you have questions about this research study, please contact
136
+ {{ investigatorInfo }} at <a href="mailto:{{ investigatorEmail }}">{{ investigatorEmail }}</a> or
137
+ the faculty member supervising this research {{ facultyInfo }}. If you have any questions regarding
138
+ your rights as a research participant, please contact the University of California Santa Cruz, Office
139
+ of Research Compliance Administration at 831-459-1473 or <a href="mailto:orca@ucsc.edu">orca&#64;ucsc.edu</a>.
140
+ </p>
141
+
142
+ <h2>4. Modifying Your Personal Information</h2>
143
+
144
+ <p>
145
+ If you are a registered user of our Services, we provide you with tools and account settings to
146
+ access or modify the personal information you provided to us and associated with your account.
147
+ </p>
148
+
149
+ <h2>5. Changes to This Policy</h2>
150
+
151
+ <p>
152
+ We may revise this document from time to time. The most current version will govern our use of
153
+ your information and terms of platform access, and will be available at
154
+ <a routerLink="/consent">{{ consentUrl }}</a>. If we make a change that, in our sole discretion,
155
+ is material, we will notify you via an email to the email address associated with your account.
156
+ By continuing to access or use the Services after those changes become effective, you agree to be
157
+ bound by the revised Terms of Service, Privacy Policy, and Research Consent.
158
+ </p>
159
+
160
+ @if (currentUser()?.consented) {
161
+ <div class="already-consented-banner">
162
+ <span class="check-icon">✓</span>
163
+ <div class="banner-title">You have already agreed to the terms and consented to participate.</div>
51
164
  </div>
52
- <button type="submit" class="btn continue-btn" [disabled]="!consentForm.checked().value()">
53
- Accept and Continue
54
- <img src="https://icongr.am/feather/arrow-right.svg?size=20&color=B2B6C7">
55
- </button>
56
- </form>
165
+ } @else {
166
+ <form [formRoot]="consentForm">
167
+ <div class="agree-container">
168
+ <mat-checkbox [color]="'primary'" [formField]="consentForm.checked"
169
+ ><span style="white-space: normal" class="permission-text"
170
+ >I have read and understood the above, agree to the Terms of Service and Privacy Policy, and
171
+ consent to participate in the research study.</span
172
+ ></mat-checkbox
173
+ >
174
+ </div>
175
+ <button type="submit" class="btn continue-btn" [disabled]="!consentForm.checked().value()">
176
+ Accept and Continue
177
+ <img src="https://icongr.am/feather/arrow-right.svg?size=20&color=B2B6C7" />
178
+ </button>
179
+ </form>
180
+ }
57
181
  </main>
@@ -74,4 +74,35 @@
74
74
  cursor: pointer;
75
75
  }
76
76
  }
77
+
78
+ .already-consented-banner {
79
+ display: flex;
80
+ align-items: center;
81
+ gap: 16px;
82
+ margin-top: 2em;
83
+ padding: 20px 24px;
84
+ background-color: #f0faf0;
85
+ border: 1px solid #c3e6c3;
86
+ border-radius: 8px;
87
+
88
+ .check-icon {
89
+ flex-shrink: 0;
90
+ display: flex;
91
+ align-items: center;
92
+ justify-content: center;
93
+ width: 28px;
94
+ height: 28px;
95
+ border-radius: 50%;
96
+ background-color: #4caf50;
97
+ color: white;
98
+ font-size: 16px;
99
+ font-weight: bold;
100
+ }
101
+
102
+ .banner-title {
103
+ font-weight: 600;
104
+ font-size: 1.05em;
105
+ color: #2e7d32;
106
+ }
107
+ }
77
108
  }
@@ -25,10 +25,16 @@ async function setup(providers: Provider[] = [], seededUsers: any[] = []) {
25
25
  };
26
26
  const routerMock = {
27
27
  navigate: jest.fn().mockReturnValue(Promise.resolve(true)),
28
+ navigateByUrl: jest.fn().mockReturnValue(Promise.resolve(true)),
28
29
  routerState: { snapshot: {} },
29
30
  };
30
31
  const activatedRouteMock = {
31
- snapshot: {},
32
+ snapshot: {
33
+ queryParamMap: {
34
+ get: jest.fn().mockReturnValue(null),
35
+ },
36
+ queryParams: {},
37
+ },
32
38
  };
33
39
 
34
40
  const view = await render(ConsentComponent, {
@@ -68,7 +74,7 @@ describe('ConsentComponent', () => {
68
74
  it('should render consent title and research study information', async () => {
69
75
  await setup();
70
76
 
71
- expect(screen.getByRole('heading', { level: 1, name: /Research Consent and Privacy Policy/i })).toBeVisible();
77
+ expect(screen.getByRole('heading', { level: 1, name: /Terms of Service, Privacy Policy, and Research Consent/i })).toBeVisible();
72
78
  expect(screen.getByText(/What will you do in the study/i)).toBeVisible();
73
79
  expect(screen.getByRole('button', { name: /Accept and Continue/i })).toBeDisabled();
74
80
  });
@@ -105,9 +111,31 @@ describe('ConsentComponent', () => {
105
111
  });
106
112
 
107
113
  await waitFor(() => {
108
- expect(navigateSpy).toHaveBeenCalledWith(['/home']);
114
+ expect(navigateSpy).toHaveBeenCalledWith(['/home'], { queryParams: {} });
109
115
  });
110
116
 
111
117
  updateSpy.mockRestore();
112
118
  });
119
+
120
+ describe('Already Consented User', () => {
121
+ beforeEach(() => {
122
+ USER_DB[0].accessState = AccessState.DONE;
123
+ USER_DB[0].consented = true;
124
+ });
125
+
126
+ it('should show the "already consented" banner instead of the form', async () => {
127
+ await setup([], [USER_DB[0]]);
128
+
129
+ expect(screen.getByText(/You have already agreed to the terms/i)).toBeVisible();
130
+ expect(screen.queryByRole('checkbox')).toBeNull();
131
+ expect(screen.queryByRole('button', { name: /Accept and Continue/i })).toBeNull();
132
+ });
133
+
134
+ it('should still display the consent page content for reading', async () => {
135
+ await setup([], [USER_DB[0]]);
136
+
137
+ expect(screen.getByRole('heading', { level: 1, name: /Terms of Service, Privacy Policy, and Research Consent/i })).toBeVisible();
138
+ expect(screen.getByText(/What will you do in the study/i)).toBeVisible();
139
+ });
140
+ });
113
141
  });
@@ -1,7 +1,6 @@
1
1
  import { Component, OnInit, ChangeDetectionStrategy, input, output, inject, WritableSignal, Signal, signal, computed, effect, Inject, Injector } from '@angular/core';
2
2
  import { Router, RouterLink, ActivatedRoute } from '@angular/router';
3
3
  import { User, AccessState } from 'src/app/core/store/user/user.model';
4
- import { handleAccess } from './consent.guard';
5
4
  import { Location } from '@angular/common';
6
5
  import { AuthStore } from 'src/app/core/store/auth/auth.store';
7
6
  import { UserStore } from 'src/app/core/store/user/user.store';
@@ -41,6 +40,7 @@ export class ConsentComponent implements OnInit {
41
40
 
42
41
  /** Constants for onboarding templates. */
43
42
  appName = 'APP_NAME [Causeway]';
43
+ organizationName = 'ORGANIZATION_NAME [the Tech4Good Lab]';
44
44
  shortProdDesc = 'PROD_DESC [provides users with opportunities to learn coding in real-world settings while contributing to non-profit causes]';
45
45
  shortResearchDesc = 'RESEARCH_DESC [how to scale opportunities for experiential learning and support collaboration around social causes]';
46
46
  authAppName = 'AUTH_APP_NAME [Google]';
@@ -50,7 +50,8 @@ export class ConsentComponent implements OnInit {
50
50
  usageDataResearchDesc = 'USAGE_DATA_RESEARCH [how to better support experiential learning online]';
51
51
  studyDoingDesc = 'STUDY_DOING [When you participate in our study, you will use our platform to learn web development and contribute code to a platform. You will also fill out a survey on your experience, and optionally, participate in a follow-up interview]';
52
52
  benefitsDesc = 'STUDY_BENEFITS [to learn web development and contribute to a project you care about]';
53
- investigatorInfo = 'INVESTIGATOR_INFO [FirstName LastName, co-Principal Investigator, email@ucsc.edu]';
53
+ investigatorInfo = 'INVESTIGATOR_INFO [FirstName LastName, co-Principal Investigator]';
54
+ investigatorEmail = 'INVESTIGATOR_EMAIL [email@ucsc.edu]';
54
55
  facultyInfo = 'FACULTY_INFO [David T. Lee, dlee105@ucsc.edu]';
55
56
 
56
57
  /** Form model */
@@ -92,7 +93,14 @@ export class ConsentComponent implements OnInit {
92
93
  accessState: AccessState.DONE,
93
94
  consented: true,
94
95
  });
95
- this.router.navigate(['/home']);
96
+
97
+ // Navigate to returnUrl or /home directly after successful submit
98
+ const returnUrl = this.route.snapshot.queryParamMap?.get('returnUrl');
99
+ if (returnUrl) {
100
+ await this.router.navigateByUrl(returnUrl);
101
+ } else {
102
+ await this.router.navigate(['/home'], { queryParams: this.route.snapshot.queryParams });
103
+ }
96
104
  } catch (e) {
97
105
  console.error(e);
98
106
  this.snackBar.open('Failed to update consent status', '', { duration: 3000 });
@@ -107,14 +115,7 @@ export class ConsentComponent implements OnInit {
107
115
  private snackBar: MatSnackBar,
108
116
  private location: Location,
109
117
  @Inject(BATCH_WRITE_SERVICE) private batch: BatchWriteService,
110
- ) {
111
- // Redirect users who have progressed past the consent stage
112
- // (i.e. neither submitting consent nor waiting) to the main app.
113
- effect(() => {
114
- const user = this.currentUser();
115
- handleAccess(user, this.router, this.route.snapshot, this.router.routerState.snapshot);
116
- });
117
- }
118
+ ) {}
118
119
 
119
120
  // --------------- LOAD AND CLEANUP --------------------
120
121
 
@@ -30,12 +30,6 @@ export function handleAccess(
30
30
  return false;
31
31
  }
32
32
 
33
- // Check 2: Does the user still need to consent?
34
- if (user && user.accessState === AccessState.DONE && user.consented) {
35
- router.navigate(['/home'], { queryParams: route.queryParams });
36
- return false;
37
- }
38
-
39
33
  return true;
40
34
  }
41
35
 
@@ -22,7 +22,13 @@ export function handleAccess(
22
22
 
23
23
  const waitingStates = [AccessState.SUBMIT_INTEREST, AccessState.WAITING];
24
24
  if (user && !waitingStates.includes(user.accessState)) {
25
- router.navigate(['/consent'], { queryParams: route.queryParams });
25
+ // Fully completed onboarding → go straight to home
26
+ if (user.consented && user.accessState === AccessState.DONE) {
27
+ router.navigate(['/home'], { queryParams: route.queryParams });
28
+ } else {
29
+ // Cleared waitlist but not yet consented → consent page
30
+ router.navigate(['/consent'], { queryParams: route.queryParams });
31
+ }
26
32
  return false;
27
33
  }
28
34
 
@@ -87,10 +87,11 @@ describe('First-Time / Onboarding Routing', () => {
87
87
  expect(router.url).toEqual('/consent');
88
88
  });
89
89
 
90
- it('should intercept navigation to /home and redirect to /consent', async () => {
90
+ it('should intercept navigation to /home and redirect to /consent with returnUrl', async () => {
91
91
  await harness.navigateByUrl('/home');
92
92
  await harness.fixture.whenStable();
93
- expect(router.url).toEqual('/consent');
93
+ expect(router.url).toContain('/consent');
94
+ expect(router.url).toContain('returnUrl');
94
95
  });
95
96
  });
96
97
 
@@ -107,17 +108,17 @@ describe('First-Time / Onboarding Routing', () => {
107
108
  expect(router.url).toEqual('/home');
108
109
  });
109
110
 
110
- it('should intercept navigation to /early-access and redirect to /consent, which redirects to /home', async () => {
111
- // earlyAccessGuard redirects to /consent, consentGuard redirects to /home
111
+ it('should intercept navigation to /early-access and redirect to /home (skipping /consent)', async () => {
112
+ // earlyAccessGuard detects consented+DONE user and redirects directly to /home
112
113
  await harness.navigateByUrl('/early-access');
113
114
  await harness.fixture.whenStable();
114
115
  expect(router.url).toEqual('/home');
115
116
  });
116
117
 
117
- it('should intercept navigation to /consent and redirect to /home', async () => {
118
+ it('should allow navigation to /consent (page is always readable)', async () => {
118
119
  await harness.navigateByUrl('/consent');
119
120
  await harness.fixture.whenStable();
120
- expect(router.url).toEqual('/home');
121
+ expect(router.url).toEqual('/consent');
121
122
  });
122
123
  });
123
124
  });