diff --git a/cmd/serve.go b/cmd/serve.go index 180ace91..b4cfe334 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -159,6 +159,7 @@ func execServe(c *cli.Context) error { webRoot := c.String("web-root") enableSignup := c.Bool("enable-signup") enableLogin := c.Bool("enable-login") + requireLogin := c.Bool("require-login") enableReservations := c.Bool("enable-reservations") upstreamBaseURL := c.String("upstream-base-url") upstreamAccessToken := c.String("upstream-access-token") @@ -408,6 +409,7 @@ func execServe(c *cli.Context) error { conf.BillingContact = billingContact conf.EnableSignup = enableSignup conf.EnableLogin = enableLogin + conf.RequireLogin = requireLogin conf.EnableReservations = enableReservations conf.EnableMetrics = enableMetrics conf.MetricsListenHTTP = metricsListenHTTP diff --git a/server/config.go b/server/config.go index 1204910e..02efd9db 100644 --- a/server/config.go +++ b/server/config.go @@ -150,6 +150,7 @@ type Config struct { BillingContact string EnableSignup bool // Enable creation of accounts via API and UI EnableLogin bool + RequireLogin bool EnableReservations bool // Allow users with role "user" to own/reserve topics EnableMetrics bool AccessControlAllowOrigin string // CORS header field to restrict access from web clients diff --git a/server/server.go b/server/server.go index ab896810..82620516 100644 --- a/server/server.go +++ b/server/server.go @@ -586,7 +586,7 @@ func (s *Server) handleWebConfig(w http.ResponseWriter, _ *http.Request, _ *visi EnableCalls: s.config.TwilioAccount != "", EnableEmails: s.config.SMTPSenderFrom != "", EnableReservations: s.config.EnableReservations, - ReuqireLogin: s.config.RequireLogin, + RequireLogin: s.config.RequireLogin, EnableWebPush: s.config.WebPushPublicKey != "", BillingContact: s.config.BillingContact, WebPushPublicKey: s.config.WebPushPublicKey, diff --git a/server/types.go b/server/types.go index 76ca699a..aa94c0e1 100644 --- a/server/types.go +++ b/server/types.go @@ -401,13 +401,13 @@ type apiConfigResponse struct { BaseURL string `json:"base_url"` AppRoot string `json:"app_root"` EnableLogin bool `json:"enable_login"` + RequireLogin bool `json:"require_login"` EnableSignup bool `json:"enable_signup"` EnablePayments bool `json:"enable_payments"` EnableCalls bool `json:"enable_calls"` EnableEmails bool `json:"enable_emails"` EnableReservations bool `json:"enable_reservations"` EnableWebPush bool `json:"enable_web_push"` - RequireLogin bool `json:"require_login"` BillingContact string `json:"billing_contact"` WebPushPublicKey string `json:"web_push_public_key"` DisallowedTopics []string `json:"disallowed_topics"` diff --git a/web/public/config.js b/web/public/config.js index 63bc97bd..5b904cd5 100644 --- a/web/public/config.js +++ b/web/public/config.js @@ -9,6 +9,7 @@ var config = { base_url: window.location.origin, // Change to test against a different server app_root: "/", enable_login: true, + require_login: true, enable_signup: true, enable_payments: false, enable_reservations: true, diff --git a/web/src/components/Navigation.jsx b/web/src/components/Navigation.jsx index 0c4da2e5..6c3b9717 100644 --- a/web/src/components/Navigation.jsx +++ b/web/src/components/Navigation.jsx @@ -164,36 +164,39 @@ const NavList = (props) => { )} - {session.exists() || !config.require_login && ( - navigate(routes.settings)} selected={location.pathname === routes.settings}> - - - - - - )} + {session.exists() || + (!config.require_login && ( + navigate(routes.settings)} selected={location.pathname === routes.settings}> + + + + + + ))} openUrl("/docs")}> - {session.exists() || !config.require_login && ( - props.onPublishMessageClick()}> - - - - - - )} - {session.exists() || !config.require_login && ( - setSubscribeDialogOpen(true)}> - - - - - - )} + {session.exists() || + (!config.require_login && ( + props.onPublishMessageClick()}> + + + + + + ))} + {session.exists() || + (!config.require_login && ( + setSubscribeDialogOpen(true)}> + + + + + + ))} {showUpgradeBanner && ( // The text background gradient didn't seem to do well with switching between light/dark mode, // So adding a `key` forces React to replace the entire component when the theme changes diff --git a/web/src/components/Notifications.jsx b/web/src/components/Notifications.jsx index a672bd0e..90f5d5c7 100644 --- a/web/src/components/Notifications.jsx +++ b/web/src/components/Notifications.jsx @@ -640,12 +640,16 @@ const NoSubscriptions = () => { {!session.exists() && config.require_login && t("notifications_no_subscriptions_login_title")} - {!session.exists() && !config.require_login && t("notifications_no_subscriptions_description", { - linktext: t("nav_button_subscribe"), - })} - {!session.exists() && config.require_login && t("notifications_no_subscriptions_login_description", { - linktext: t("action_bar_sign_in"), - })} + {!session.exists() && + !config.require_login && + t("notifications_no_subscriptions_description", { + linktext: t("nav_button_subscribe"), + })} + {!session.exists() && + config.require_login && + t("notifications_no_subscriptions_login_description", { + linktext: t("action_bar_sign_in"), + })} diff --git a/web/src/components/Preferences.jsx b/web/src/components/Preferences.jsx index 3b854484..98f0ae19 100644 --- a/web/src/components/Preferences.jsx +++ b/web/src/components/Preferences.jsx @@ -66,20 +66,20 @@ const maybeUpdateAccountSettings = async (payload) => { }; const Preferences = () => { - if (!session.exists() or !config.requireLogin) { + if (!session.exists() || !config.require_login) { window.location.href = routes.app; return <>; } - return ( - - - - - - - - - ); + return ( + + + + + + + + + ); }; const Notifications = () => {