kunwp1 commented on code in PR #9498:
URL: https://github.com/apache/texera/pull/9498#discussion_r4596042712
##########
common/dao/src/main/scala/org/apache/texera/dao/SiteSettings.scala:
##########
@@ -77,14 +95,5 @@ object SiteSettings {
raw.flatMap(s => Try(parse(s.trim)).toOption).getOrElse(default)
private def readAndParse[T](key: String, default: => T)(parse: String => T):
T =
- Try {
- val raw = SqlServer
- .getInstance()
- .createDSLContext()
- .select(SITE_SETTINGS.VALUE)
- .from(SITE_SETTINGS)
- .where(SITE_SETTINGS.KEY.eq(key))
- .fetchOneInto(classOf[String])
- parseOrDefault(Option(raw), default)(parse)
- }.getOrElse(default)
+ lookup(key).toOption.map(parseOrDefault(_,
default)(parse)).getOrElse(default)
Review Comment:
`parseOrDefault` already falls back on `None`, so this can be
`parseOrDefault(lookup(key).toOption.flatten, default)(parse)`. The object doc
at the top also still says read failures are swallowed by "the outer Try on the
read path". That `Try` now lives in `lookup`, which hands failures back, and
only the getters swallow them.
##########
common/config/src/test/scala/org/apache/texera/common/config/DefaultsConfigSpec.scala:
##########
@@ -38,6 +38,19 @@ class DefaultsConfigSpec extends AnyFlatSpec with Matchers {
)
}
+ // A REGULAR account can run code on the server, so open sign-up has to be a
deployment's own
+ // choice rather than what it gets by leaving USER_SYS_INVITE_ONLY unset.
+ "DefaultsConfig.inviteOnly" should "default to invite-only" in {
+ ifUnset("USER_SYS_INVITE_ONLY")(DefaultsConfig.inviteOnly shouldBe true)
+ }
+
+ // HOCON also accepts yes/no and on/off, but every reader of the stored row
expects true or false:
+ // the backend reads anything else as on, and so does the admin card. Holds
whatever spelling
+ // USER_SYS_INVITE_ONLY uses; run with USER_SYS_INVITE_ONLY=off to exercise
it.
+ it should "seed the parsed value, not the variable's own spelling" in {
Review Comment:
CI never sets `USER_SYS_INVITE_ONLY`, so both sides here are `"true"` and
this case passes with or without the fix. It only bites when you run it with
`=off`. If the flattener takes a `Config`, the spellings can be pinned without
the environment:
```scala
val allDefaults: Map[String, String] = seedValues(conf)
private[config] def seedValues(source: Config): Map[String, String] = {
val entries = source
...
entries.toMap.updated(shortKey(InviteOnlyPath),
source.getBoolean(InviteOnlyPath).toString)
}
```
```scala
Seq("off" -> "false", "no" -> "false", "on" -> "true", "yes" ->
"true").foreach {
case (spelling, seeded) =>
DefaultsConfig
.seedValues(ConfigFactory.parseString(s"user-sys.invite_only =
$spelling"))
.get("invite_only") shouldBe Some(seeded)
}
```
With the env var unset, this fails once the `.updated(...)` is dropped and
passes as is.
Not for this PR: the `gui.tabs.*_enabled` leaves have the same raw-spelling
issue. `GUI_TABS_HUB_ENABLED=on` seeds `"on"`, and the dashboard checks `===
"true"`, so the tab disappears.
##########
config-service/src/main/scala/org/apache/texera/service/resource/ConfigResource.scala:
##########
@@ -72,7 +72,9 @@ class ConfigResource {
),
"attributionEnabled" -> GuiConfig.guiAttributionEnabled,
"deploymentVersionCheckEnabled" ->
GuiConfig.guiDeploymentVersionCheckEnabled,
- "inviteOnly" -> UserSystemConfig.inviteOnly,
+ // Read per request: admins switch it on the settings page, and the
login flow uses it to
+ // decide whether an INACTIVE sign-in sees the pending-approval screen.
Review Comment:
Since 9cbc4717b the login flow doesn't read this anymore; only the sign-up
hint does. Maybe:
```scala
// Read per request: admins switch it on the settings page, and the
sign-up form uses it to
// say whether a new account has to wait for an admin.
```
##########
config-service/src/main/scala/org/apache/texera/service/resource/ConfigResource.scala:
##########
@@ -122,8 +124,8 @@ class ConfigResource {
@Path("/user-system")
def getUserSystemConfig: Map[String, Any] =
Map(
- // flags from the user-system.conf
- "inviteOnly" -> UserSystemConfig.inviteOnly
+ // the admin-editable invite_only site setting
+ "inviteOnly" -> InviteOnly.enabled
Review Comment:
Now that `loginWithExistingToken` checks the role alone, nothing reads
`inviteOnly` after login, and `/pre-login` already serves it to the sign-up
hint. So this endpoint, `UserSystemConfig`, and the third request in
`GuiConfigService.loadPostLogin` can go, which saves a request and a DB read on
every sign-in. Fine as a follow-up.
##########
frontend/src/app/common/service/user/auth.service.ts:
##########
@@ -227,7 +227,10 @@ export class AuthService {
return undefined;
}
- if (this.config.env.inviteOnly && role === Role.INACTIVE) {
+ // INACTIVE means waiting for an admin, whatever the invite-only switch
says now: an account that
+ // signed up while it was on stays INACTIVE after it is turned off, and
every request it makes is
+ // refused, so it gets the pending screen rather than an empty dashboard.
+ if (role === Role.INACTIVE) {
Review Comment:
INACTIVE is also what an admin picks on the Users page to deactivate
someone. Accounts that signed up while invite-only was off never filled in a
joining reason, so if one of them is deactivated later, its next sign-in now
opens the joining-reason form and then Access Pending. Before this it got the
refused dashboard. Probably fine, maybe better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]