The GitHub Actions job "Required Checks" on 
texera.git/gh-readonly-queue/main/pr-9498-82224eaca8d2e10a9b077cb1bf406601fdc6ff18
 has failed.
Run started by GitHub user aglinxinyuan (triggered by aglinxinyuan).

Head commit for run:
095da7b4619cf2e0dd2d87bbd90bb0ceb64bf0f1 / Xinyuan Lin <[email protected]>
feat: honor invite-only at sign-up and add an admin switch (#9498)

### What changes were proposed in this PR?

`USER_SYS_INVITE_ONLY` now decides the role a new account starts with,
and admins can switch it on Admin → Settings without a restart.

| A new account, while invite-only is | Before | After |
| --- | --- | --- |
| off | INACTIVE; stays on the sign-up page, told to contact an
administrator; every dashboard request refused | REGULAR; opens the
dashboard |
| on | INACTIVE; pending-approval screen | unchanged |

- **Sign-up roles.** These sign-ups start REGULAR while invite-only is
off, and INACTIVE while it is on:
  - local sign-up, with or without email verification;
  - the first Google or Apple sign-in;
  - a sign-up that claims a dataset-contributor placeholder.

An account from a provider that asserts no email (ORCID) stays INACTIVE
until it supplies one, and then gets the same role. Staying INACTIVE
until then is also what lets that step adopt a placeholder. Accounts
already waiting for approval, and roles an admin set, are never changed.
- **An admin setting.** Invite-only is now the `invite_only` site
setting, read on every sign-up. Admin → Settings has a Registration card
with an Invite Only switch. `USER_SYS_INVITE_ONLY`, now declared in
`default.conf`, sets its value the first time config-service starts,
like the page's other settings, and Reset restores it. The value is
stored as `true` or `false` whatever spelling the variable uses (`yes`,
`off`, …). `/config/pre-login` reports the stored value to the sign-up
form. Nothing reads it after sign-in any more, so `/config/user-system`,
which served only this flag, is removed along with the request the
frontend made to it on every sign-in. Each sign-up reads the setting
before it opens its transaction, so a burst of sign-ups cannot have each
one hold a pooled connection while it waits for a second.
- **Every boolean default.** The same now holds for every setting
`default.conf` declares as a boolean: the sidebar tab switches
(`GUI_TABS_*_ENABLED`) and the reset flag are stored as `true` or
`false` too. Before, `GUI_TABS_HUB_ENABLED=on` stored `on`, and the
dashboard and the admin page, which accept only `"true"`, hid the Hub
tab. A value that is not a boolean now stops config-service at startup,
as `USER_SYS_INVITE_ONLY` and the reset flag already did. Rows a
deployment already stored as `on` stay until an admin saves or resets
that switch.
- **On by default, and closed when in doubt.** A REGULAR account can run
code on the server, so opening sign-up has to be a deployment's explicit
choice. A deployment that never set the variable keeps its new accounts
INACTIVE, as before. The configured value applies only while no row is
stored: a read that fails, or a row that is neither true nor false,
keeps sign-up closed and logs a warning. The admin card likewise shows
anything but an explicit `false` as on, because Save writes whatever the
switch shows.
- **Pending accounts.** Any INACTIVE account gets the pending-approval
screen when it signs in, whatever the switch says now. So accounts still
waiting when an admin turns invite-only off are not dropped onto a
dashboard that refuses every request. The same goes for an account an
admin deactivated, which before got this screen only on invite-only
deployments.
- **Sign-up page.** When the new account is usable, the page says so and
opens the dashboard. The "contact the administrator" hint and message
appear only while invite-only is on, or while the account is still
INACTIVE.

| | Before | After |
| --- | --- | --- |
| Admin → Settings | ![Admin settings
before](https://raw.githubusercontent.com/aglinxinyuan/texera/d7e48c543320338c4b5c0fff9ead279d6b3df482/admin-settings-before.png)
| ![Admin settings
after](https://raw.githubusercontent.com/aglinxinyuan/texera/d7e48c543320338c4b5c0fff9ead279d6b3df482/admin-settings-after.png)
|
| After signing up, invite-only off | ![After sign-up
before](https://raw.githubusercontent.com/aglinxinyuan/texera/d7e48c543320338c4b5c0fff9ead279d6b3df482/signup-result-before.png)
| ![After sign-up
after](https://raw.githubusercontent.com/aglinxinyuan/texera/d7e48c543320338c4b5c0fff9ead279d6b3df482/signup-result-after.png)
|

### Any related issues, documentation, discussions?

Closes #9497.

### How was this PR tested?

Unit tests, all passing:

```
sbt "DAO/testOnly org.apache.texera.dao.SiteSettingsSpec" "Config/test" 
"Auth/testOnly org.apache.texera.auth.InviteOnlySpec" "ConfigService/test" 
"WorkflowExecutionService/testOnly org.apache.texera.web.resource.auth.*"
cd frontend && ng test --watch=false 
--include=src/app/common/service/gui-config.service.spec.ts 
--include=src/app/dashboard/component/admin/settings/admin-settings.component.spec.ts
 --include=src/app/hub/component/login/texera-login.component.spec.ts 
--include=src/app/common/service/user/auth.service.spec.ts
```

That is 15 SiteSettings, 105 Config, 9 InviteOnly, 43 ConfigService and
141 amber auth cases, plus 12 GuiConfigService, 62 admin-settings, 64
login and 39 AuthService cases. The new cases run with invite-only both
on and off. They cover local sign-up, register/verify, Google and Apple,
placeholder claims, the add-email step and placeholder adoption, and a
switch reaching the very next registration. They check that pending
accounts and admin-set roles are left alone, that a missing row falls
back to the seed while a failed read or an unreadable row keeps sign-up
closed, that invite-only, every sidebar tab switch and the reset flag
are seeded as true or false whatever the spelling (`off`, `no`, `on`,
`yes`) while a value that is not a boolean is refused, and that a fresh
deployment seeds invite-only on. They also cover the admin card's load,
save, reset and its guard against saving before the load, the sign-up
page's outcomes and hint, the pending screen for an INACTIVE sign-in
while invite-only is off, and a sign-in that no longer asks for
`/config/user-system`.

Lint: `scalafmtCheckAll` and `scalafixAll --check` on DAO, Config, Auth,
ConfigService and WorkflowExecutionService; `prettier-eslint
--list-different` and `eslint` on the changed frontend files.

Manual check: config-service and the web server ran against a fresh
database, with `USER_SYS_INVITE_ONLY` unset.
1. `invite_only` was seeded `true`, and a sign-up came out INACTIVE with
the Request access dialog.
2. After turning the switch off on Admin → Settings, with no restart,
the next sign-up was REGULAR and opened the dashboard.
3. After turning it back on, the next sign-up was INACTIVE again.
4. After the second review round, signing in requested `/config/gui` and
`/config/amber` but not `/config/user-system`, which now answers 404,
and the sign-up form still told new accounts to ask for activation.

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Report URL: https://github.com/apache/texera/actions/runs/44060273245

With regards,
GitHub Actions via GitBox

Reply via email to