Skip to content

Commit bb1ac6e

Browse files
committed
ok
1 parent 04c298c commit bb1ac6e

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

coderd/users.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -989,11 +989,15 @@ func (api *API) userAppearanceSettings(rw http.ResponseWriter, r *http.Request)
989989

990990
themePreference, err := api.Database.GetUserAppearanceSettings(ctx, user.ID)
991991
if err != nil {
992-
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
993-
Message: "Internal error updating user.",
994-
Detail: err.Error(),
995-
})
996-
return
992+
if !errors.Is(err, sql.ErrNoRows) {
993+
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
994+
Message: "Error reading user settings.",
995+
Detail: err.Error(),
996+
})
997+
return
998+
}
999+
1000+
themePreference = ""
9971001
}
9981002

9991003
httpapi.Write(ctx, rw, http.StatusOK, codersdk.UserAppearanceSettings{

site/site.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,10 @@ func (h *Handler) renderHTMLWithState(r *http.Request, filePath string, state ht
437437
eg.Go(func() error {
438438
var err error
439439
themePreference, err = h.opts.Database.GetUserAppearanceSettings(ctx, apiKey.UserID)
440+
if errors.Is(err, sql.ErrNoRows) {
441+
themePreference = ""
442+
return nil
443+
}
440444
return err
441445
})
442446
eg.Go(func() error {

site/site_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ func TestInjection(t *testing.T) {
6565

6666
handler.ServeHTTP(rw, r)
6767
require.Equal(t, http.StatusOK, rw.Code)
68+
fmt.Println("oh boy oh boy oh boy")
69+
fmt.Println(rw.Body.String())
70+
fmt.Println("oh boy oh boy oh boy")
6871
var got codersdk.User
6972
err := json.Unmarshal([]byte(html.UnescapeString(rw.Body.String())), &got)
7073
require.NoError(t, err)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy