aglinxinyuan commented on code in PR #9498:
URL: https://github.com/apache/texera/pull/9498#discussion_r4595714322


##########
common/auth/src/main/scala/org/apache/texera/auth/InviteOnly.scala:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.auth
+
+import org.apache.texera.common.config.DefaultsConfig
+import org.apache.texera.dao.SiteSettings
+
+/**
+  * Whether a new account has to wait for an admin's approval before it can be 
used.
+  *
+  * The switch is the `invite_only` site setting, which admins flip on the 
Admin Settings page. It
+  * is read on every call, so a change reaches the next sign-up without a 
restart. default.conf's
+  * `user-sys.invite_only` (USER_SYS_INVITE_ONLY) seeds that row and stands in 
whenever the row is
+  * missing, unreadable or not a boolean.
+  */
+object InviteOnly {
+
+  /** The `site_settings` key, which is also the default.conf leaf that seeds 
it. */
+  val SettingKey = "invite_only"
+
+  def enabled: Boolean = SiteSettings.getBoolean(SettingKey, 
DefaultsConfig.inviteOnly)

Review Comment:
   Agreed. `InviteOnly` now reads the row through a new `SiteSettings.lookup` 
and uses the seed only when no row exists; a failed read, or a value other than 
true/false, keeps sign-up closed and logs a warning (9cbc4717bb, tests in 
7e06f43727).
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
   



##########
common/config/src/main/scala/org/apache/texera/common/config/DefaultsConfig.scala:
##########
@@ -27,6 +27,11 @@ object DefaultsConfig {
   val reinit: Boolean =
     
conf.getBoolean("config-service.always-reset-configurations-to-default-values")
 
+  // Typed rather than read off `allDefaults`: HOCON's parsing keeps the 
spellings
+  // USER_SYS_INVITE_ONLY has always accepted (yes/no, on/off), and an 
unreadable value stops
+  // config-service at startup, when it loads this object to seed 
site_settings.
+  val inviteOnly: Boolean = conf.getBoolean("user-sys.invite_only")

Review Comment:
   Good catch. `allDefaults` now seeds the parsed value as you suggested, and 
`DefaultsConfigSpec` pins `allDefaults("invite_only") == inviteOnly.toString`: 
under `USER_SYS_INVITE_ONLY=off` it failed with `Some("off")` before and passes 
now (9cbc4717bb).
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
   



##########
frontend/src/app/hub/component/login/texera-login.component.ts:
##########
@@ -339,7 +345,23 @@ export class TexeraLoginComponent implements OnInit {
         }),
         untilDestroyed(this)
       )
-      .subscribe(() => this.notificationService.success(ACCOUNT_CREATED));
+      .subscribe(() => this.finishSignup());
+  }
+
+  /**
+   * Close a sign-up that created the account. Registering signs the user in, 
so an account that can
+   * already be used (invite-only off) goes where a sign-in would. An account 
waiting for an admin is
+   * INACTIVE: the session is signed straight back out, or kept by a page 
whose config predates
+   * invite-only being turned on. Either way the user stays here and is told 
to wait.
+   */
+  private finishSignup(): void {
+    const user = this.userService.getCurrentUser();
+    if (user !== undefined && user.role !== Role.INACTIVE) {
+      this.notificationService.success(ACCOUNT_READY);
+      this.navigateAfterLogin();
+    } else {
+      this.notificationService.success(ACCOUNT_PENDING);
+    }

Review Comment:
   Agreed. `loginWithExistingToken` now shows the pending flow for any INACTIVE 
account, so the flag only drives the sign-up hint; a new `AuthService` spec 
case signs in an INACTIVE account while invite-only is off (9cbc4717bb).
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
   



-- 
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]

Reply via email to