Skip to content

chore: add "user_configs" db table #16564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Mar 5, 2025
Merged
Prev Previous commit
Next Next commit
ok
  • Loading branch information
aslilac committed Feb 14, 2025
commit bb1ac6e704a24d94e448996da485b47899246930
14 changes: 9 additions & 5 deletions coderd/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,11 +989,15 @@ func (api *API) userAppearanceSettings(rw http.ResponseWriter, r *http.Request)

themePreference, err := api.Database.GetUserAppearanceSettings(ctx, user.ID)
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error updating user.",
Detail: err.Error(),
})
return
if !errors.Is(err, sql.ErrNoRows) {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Error reading user settings.",
Detail: err.Error(),
})
return
}

themePreference = ""
}

httpapi.Write(ctx, rw, http.StatusOK, codersdk.UserAppearanceSettings{
Expand Down
4 changes: 4 additions & 0 deletions site/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ func (h *Handler) renderHTMLWithState(r *http.Request, filePath string, state ht
eg.Go(func() error {
var err error
themePreference, err = h.opts.Database.GetUserAppearanceSettings(ctx, apiKey.UserID)
if errors.Is(err, sql.ErrNoRows) {
themePreference = ""
return nil
}
return err
})
eg.Go(func() error {
Expand Down
3 changes: 3 additions & 0 deletions site/site_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ func TestInjection(t *testing.T) {

handler.ServeHTTP(rw, r)
require.Equal(t, http.StatusOK, rw.Code)
fmt.Println("oh boy oh boy oh boy")
fmt.Println(rw.Body.String())
fmt.Println("oh boy oh boy oh boy")
var got codersdk.User
err := json.Unmarshal([]byte(html.UnescapeString(rw.Body.String())), &got)
require.NoError(t, err)
Expand Down
Loading