Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: signup is not allowed if password login is disabled (#2776)

Wen Sune4488da96ec5
diff --git a/api/v1/auth.go b/api/v1/auth.go
index 24cbdcd82..93123b3ff 100644
--- a/api/v1/auth.go
+++ b/api/v1/auth.go
@@ -324,6 +324,23 @@ func (s *APIV1Service) SignUp(c echo.Context) error {
if !allowSignUpSettingValue {
return echo.NewHTTPError(http.StatusUnauthorized, "signup is disabled").SetInternal(err)
}
+
+ disablePasswordLoginSystemSetting, err := s.Store.GetSystemSetting(ctx, &store.FindSystemSetting{
+ Name: SystemSettingDisablePasswordLoginName.String(),
+ })
+ if err != nil {
+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find system setting").SetInternal(err)
+ }
+ if disablePasswordLoginSystemSetting != nil {
+ disablePasswordLogin := false
+ err = json.Unmarshal([]byte(disablePasswordLoginSystemSetting.Value), &disablePasswordLogin)
+ if err != nil {
+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal system setting").SetInternal(err)
+ }
+ if disablePasswordLogin {
+ return echo.NewHTTPError(http.StatusUnauthorized, "password login is deactivated")
+ }
+ }
}
passwordHash, err := bcrypt.GenerateFromPassword([]byte(signup.Password), bcrypt.DefaultCost)