loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'feat: don't allow blocking the doer' (#6411) from gusted/forgejo-org-block-yourown into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6411
Reviewed-by: 0ko <0ko@noreply.codeberg.org>

+21
+1
options/locale/locale_en-US.ini
··· 1042 1042 blocked_since = Blocked since %s 1043 1043 user_unblock_success = The user has been unblocked successfully. 1044 1044 user_block_success = The user has been blocked successfully. 1045 + user_block_yourself = You cannot block yourself. 1045 1046 1046 1047 [repo] 1047 1048 rss.must_be_on_branch = You must be on a branch to have an RSS feed.
+6
routers/web/org/setting/blocked_users.go
··· 53 53 return 54 54 } 55 55 56 + if u.ID == ctx.Doer.ID { 57 + ctx.Flash.Error(ctx.Tr("settings.user_block_yourself")) 58 + ctx.Redirect(ctx.Org.OrgLink + "/settings/blocked_users") 59 + return 60 + } 61 + 56 62 if err := user_service.BlockUser(ctx, ctx.Org.Organization.ID, u.ID); err != nil { 57 63 ctx.ServerError("BlockUser", err) 58 64 return
+14
tests/integration/block_test.go
··· 147 147 session.MakeRequest(t, req, http.StatusInternalServerError) 148 148 }) 149 149 }) 150 + 151 + t.Run("Block the doer", func(t *testing.T) { 152 + defer tests.PrintCurrentTest(t)() 153 + 154 + req := NewRequestWithValues(t, "POST", org.OrganisationLink()+"/settings/blocked_users/block", map[string]string{ 155 + "_csrf": GetCSRF(t, session, org.OrganisationLink()+"/settings/blocked_users"), 156 + "uname": doer.Name, 157 + }) 158 + session.MakeRequest(t, req, http.StatusSeeOther) 159 + assert.False(t, unittest.BeanExists(t, &user_model.BlockedUser{BlockID: doer.ID, UserID: org.ID})) 160 + flashCookie := session.GetCookie(forgejo_context.CookieNameFlash) 161 + assert.NotNil(t, flashCookie) 162 + assert.EqualValues(t, "error%3DYou%2Bcannot%2Bblock%2Byourself.", flashCookie.Value) 163 + }) 150 164 } 151 165 152 166 // TestBlockActions ensures that certain actions cannot be performed as a doer