Unverified Commit 34700a4c authored by boojack's avatar boojack Committed by GitHub

chore: check allow sign up setting in sso (#1620)

parent b6564bcd
...@@ -101,6 +101,24 @@ func (s *Server) registerAuthRoutes(g *echo.Group, secret string) { ...@@ -101,6 +101,24 @@ func (s *Server) registerAuthRoutes(g *echo.Group, secret string) {
return echo.NewHTTPError(http.StatusInternalServerError, "Incorrect login credentials, please try again") return echo.NewHTTPError(http.StatusInternalServerError, "Incorrect login credentials, please try again")
} }
if user == nil { if user == nil {
allowSignUpSetting, err := s.Store.FindSystemSetting(ctx, &api.SystemSettingFind{
Name: api.SystemSettingAllowSignUpName,
})
if err != nil && common.ErrorCode(err) != common.NotFound {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find system setting").SetInternal(err)
}
allowSignUpSettingValue := false
if allowSignUpSetting != nil {
err = json.Unmarshal([]byte(allowSignUpSetting.Value), &allowSignUpSettingValue)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal system setting allow signup").SetInternal(err)
}
}
if !allowSignUpSettingValue {
return echo.NewHTTPError(http.StatusUnauthorized, "signup is disabled").SetInternal(err)
}
userCreate := &api.UserCreate{ userCreate := &api.UserCreate{
Username: userInfo.Identifier, Username: userInfo.Identifier,
// The new signup user should be normal user by default. // The new signup user should be normal user by default.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment