feat: add option to hide the login button from public-facing pages (#3922)
Co-authored-by: Henrique Dias <mail@hacdias.com>pull/3884/head
parent
9d44932dba
commit
ac7b49c148
|
|
@ -31,6 +31,7 @@ func addConfigFlags(flags *pflag.FlagSet) {
|
|||
addServerFlags(flags)
|
||||
addUserFlags(flags)
|
||||
flags.BoolP("signup", "s", false, "allow users to signup")
|
||||
flags.Bool("hide-login-button", false, "hide login button from public pages")
|
||||
flags.Bool("create-user-dir", false, "generate user's home directory automatically")
|
||||
flags.Uint("minimum-password-length", settings.DefaultMinimumPasswordLength, "minimum password length for new users")
|
||||
flags.String("shell", "", "shell command to which other commands should be appended")
|
||||
|
|
@ -192,9 +193,10 @@ func printSettings(ser *settings.Server, set *settings.Settings, auther auth.Aut
|
|||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
||||
|
||||
fmt.Fprintf(w, "Sign up:\t%t\n", set.Signup)
|
||||
fmt.Fprintf(w, "Hide Login Button:\t%t\n", set.HideLoginButton)
|
||||
fmt.Fprintf(w, "Create User Dir:\t%t\n", set.CreateUserDir)
|
||||
fmt.Fprintf(w, "Minimum Password Length:\t%d\n", set.MinimumPasswordLength)
|
||||
fmt.Fprintf(w, "Auth method:\t%s\n", set.AuthMethod)
|
||||
fmt.Fprintf(w, "Auth Method:\t%s\n", set.AuthMethod)
|
||||
fmt.Fprintf(w, "Shell:\t%s\t\n", strings.Join(set.Shell, " "))
|
||||
fmt.Fprintln(w, "\nBranding:")
|
||||
fmt.Fprintf(w, "\tName:\t%s\n", set.Branding.Name)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,11 @@ override the options.`,
|
|||
return err
|
||||
}
|
||||
|
||||
hideLoginButton, err := getBool(flags, "hide-login-button")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
createUserDir, err := getBool(flags, "create-user-dir")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -84,6 +89,7 @@ override the options.`,
|
|||
s := &settings.Settings{
|
||||
Key: key,
|
||||
Signup: signup,
|
||||
HideLoginButton: hideLoginButton,
|
||||
CreateUserDir: createUserDir,
|
||||
MinimumPasswordLength: minLength,
|
||||
Shell: convertCmdStrToCmdArray(shell),
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ you want to change. Other options will remain unchanged.`,
|
|||
ser.Port, err = getString(flags, flag.Name)
|
||||
case "log":
|
||||
ser.Log, err = getString(flags, flag.Name)
|
||||
case "hide-login-button":
|
||||
set.HideLoginButton, err = getBool(flags, flag.Name)
|
||||
case "signup":
|
||||
set.Signup, err = getBool(flags, flag.Name)
|
||||
case "auth.method":
|
||||
|
|
|
|||
|
|
@ -420,6 +420,7 @@ func quickSetup(flags *pflag.FlagSet, d pythonData) error {
|
|||
set := &settings.Settings{
|
||||
Key: generateKey(),
|
||||
Signup: false,
|
||||
HideLoginButton: true,
|
||||
CreateUserDir: false,
|
||||
MinimumPasswordLength: settings.DefaultMinimumPasswordLength,
|
||||
UserHomeBasePath: settings.DefaultUsersHomeBasePath,
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@
|
|||
</template>
|
||||
<template v-else>
|
||||
<router-link
|
||||
v-if="!hideLoginButton"
|
||||
class="action"
|
||||
to="/login"
|
||||
:aria-label="$t('sidebar.login')"
|
||||
|
|
@ -124,6 +125,7 @@ import * as auth from "@/utils/auth";
|
|||
import {
|
||||
version,
|
||||
signup,
|
||||
hideLoginButton,
|
||||
disableExternal,
|
||||
disableUsedPercentage,
|
||||
noAuth,
|
||||
|
|
@ -153,6 +155,7 @@ export default {
|
|||
return this.currentPromptName === "sidebar";
|
||||
},
|
||||
signup: () => signup,
|
||||
hideLoginButton: () => hideLoginButton,
|
||||
version: () => version,
|
||||
disableExternal: () => disableExternal,
|
||||
disableUsedPercentage: () => disableUsedPercentage,
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@
|
|||
"allowNew": "Create new files and directories",
|
||||
"allowPublish": "Publish new posts and pages",
|
||||
"allowSignup": "Allow users to signup",
|
||||
"hideLoginButton": "Hide the login button from public pages",
|
||||
"avoidChanges": "(leave blank to avoid changes)",
|
||||
"branding": "Branding",
|
||||
"brandingDirectoryPath": "Branding directory path",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
interface ISettings {
|
||||
signup: boolean;
|
||||
createUserDir: boolean;
|
||||
hideLoginButton: boolean;
|
||||
minimumPasswordLength: number;
|
||||
userHomeBasePath: string;
|
||||
defaults: SettingsDefaults;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ const enableExec: boolean = window.FileBrowser.EnableExec;
|
|||
const tusSettings = window.FileBrowser.TusSettings;
|
||||
const origin = window.location.origin;
|
||||
const tusEndpoint = `/api/tus`;
|
||||
const hideLoginButton = window.FileBrowser.HideLoginButton;
|
||||
|
||||
export {
|
||||
name,
|
||||
|
|
@ -39,4 +40,5 @@ export {
|
|||
tusSettings,
|
||||
origin,
|
||||
tusEndpoint,
|
||||
hideLoginButton,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@
|
|||
{{ t("settings.createUserDir") }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input type="checkbox" v-model="settings.hideLoginButton" />
|
||||
{{ t("settings.hideLoginButton") }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label class="small">{{ t("settings.userHomeBasePath") }}</label>
|
||||
<input
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
type settingsData struct {
|
||||
Signup bool `json:"signup"`
|
||||
HideLoginButton bool `json:"hideLoginButton"`
|
||||
CreateUserDir bool `json:"createUserDir"`
|
||||
MinimumPasswordLength uint `json:"minimumPasswordLength"`
|
||||
UserHomeBasePath string `json:"userHomeBasePath"`
|
||||
|
|
@ -24,6 +25,7 @@ type settingsData struct {
|
|||
var settingsGetHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||
data := &settingsData{
|
||||
Signup: d.settings.Signup,
|
||||
HideLoginButton: d.settings.HideLoginButton,
|
||||
CreateUserDir: d.settings.CreateUserDir,
|
||||
MinimumPasswordLength: d.settings.MinimumPasswordLength,
|
||||
UserHomeBasePath: d.settings.UserHomeBasePath,
|
||||
|
|
@ -55,6 +57,7 @@ var settingsPutHandler = withAdmin(func(_ http.ResponseWriter, r *http.Request,
|
|||
d.settings.Tus = req.Tus
|
||||
d.settings.Shell = req.Shell
|
||||
d.settings.Commands = req.Commands
|
||||
d.settings.HideLoginButton = req.HideLoginButton
|
||||
|
||||
err = d.store.Settings.Save(d.settings)
|
||||
return errToStatus(err), err
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ func handleWithStaticData(w http.ResponseWriter, _ *http.Request, d *data, fSys
|
|||
"ResizePreview": d.server.ResizePreview,
|
||||
"EnableExec": d.server.EnableExec,
|
||||
"TusSettings": d.settings.Tus,
|
||||
"HideLoginButton": d.settings.HideLoginButton,
|
||||
}
|
||||
|
||||
if d.settings.Branding.Files != "" {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ type AuthMethod string
|
|||
type Settings struct {
|
||||
Key []byte `json:"key"`
|
||||
Signup bool `json:"signup"`
|
||||
HideLoginButton bool `json:"hideLoginButton"`
|
||||
CreateUserDir bool `json:"createUserDir"`
|
||||
UserHomeBasePath string `json:"userHomeBasePath"`
|
||||
Defaults UserDefaults `json:"defaults"`
|
||||
|
|
|
|||
Loading…
Reference in New Issue