aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web
Commit message (Collapse)AuthorAgeFilesLines
* Refactor repo clone button and repo clone links, fix JS error on empty repo ↵wxiaoguang2022-03-293-7/+2
| | | | | | | | | | | | | | | | | page (#19208) The last PR about clone buttons introduced an JS error when visiting an empty repo page: * https://github.com/go-gitea/gitea/pull/19028 * `Uncaught ReferenceError: isSSH is not defined`, because the variables are scoped and doesn't share between sub templates. This: 1. Simplify `templates/repo/clone_buttons.tmpl` and make code clear 2. Move most JS code into `initRepoCloneLink` 3. Remove unused `CloneLink.Git` 4. Remove `ctx.Data["DisableSSH"] / ctx.Data["ExposeAnonSSH"] / ctx.Data["DisableHTTP"]`, and only set them when is is needed (eg: deploy keys / ssh keys) 5. Introduce `Data["CloneButton*"]` to provide data for clone buttons and links 6. Introduce `Data["RepoCloneLink"]` for the repo clone link (not the wiki) 7. Remove most `ctx.Data["PageIsWiki"]` because it has been set in the `/wiki` middleware 8. Remove incorrect `quickstart` class in `migrating.tmpl`
* Let web and API routes have different auth methods group (#19168)Lunny Xiao2022-03-283-1/+58
| | | | | | | | | | | | | * remove the global methods but create dynamiclly * Fix lint * Fix windows lint * Fix windows lint * some improvements Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Only send webhook events to active system webhooks and only deliver to ↵zeripath2022-03-281-1/+2
| | | | | | | | | | | | | | | | | active hooks (#19234) There is a bug in the system webhooks whereby the active state is not checked when webhooks are prepared and there is a bug that deactivating webhooks do not prevent queued deliveries. * Only add SystemWebhooks to the prepareWebhooks list if they are active * At the time of delivery if the underlying webhook is not active mark it as "delivered" but with a failed delivery so it does not get delivered. Fix #19220 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Add `ContextUser` to http request context (#18798)KN4CK3R2022-03-265-135/+67
| | | | | This PR adds a middleware which sets a ContextUser (like GetUserByParams before) in a single place which can be used by other methods. For routes which represent a repo or org the respective middlewares set the field too. Also fix a bug in modules/context/org.go during refactoring.
* Fix showing issues in your repositories (#18916)Gusted2022-03-231-4/+47
| | | | | - Make a restriction on which issues can be shown based on if you the user or team has write permission to the repository. - Fixes a issue whereby you wouldn't see any associated issues with a specific team on a organization if you wasn't a member(fixed by zeroing the User{ID} in the options). - Resolves #18913
* Fix compare link in active feeds for new branch (#19149)a10121127962022-03-231-0/+7
| | | | | | | | | | | | | | | | | | | When a new branch is pushed the old SHA is always listed as the empty sha and thus the compare link that is created does not work correctly. Therefore when creating the compare link for new branches: 1. Attempt to get the parent of the first commit and use that as the basis for the compare link. 2. If this is not possible make a comparison to the default branch 3. Finally if that is not possible simply do not show a compare link. However, there are multiple broken compare links remaining therefore, in order for these to not break we will simply make the compare link redirect to the default branch. Fix #19144 Signed-off-by: a1012112796 <1012112796@qq.com> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Andrew Thornton <art27@cantab.net>
* Update HTTP status codes to modern codes (#18063)KN4CK3R2022-03-2322-74/+72
| | | | | | * 2xx/3xx/4xx/5xx -> http.Status... * http.StatusFound -> http.StatusTemporaryRedirect * http.StatusMovedPermanently -> http.StatusPermanentRedirect
* Clean paths when looking in Storage (#19124)zeripath2022-03-221-11/+10
| | | | | | | | | | | | | * Clean paths when looking in Storage Ensure paths are clean for minio aswell as local storage. Use url.Path not RequestURI/EscapedPath in storageHandler. Signed-off-by: Andrew Thornton <art27@cantab.net> * Apply suggestions from code review Co-authored-by: Lauris BH <lauris@nix.lv>
* Use the new/choose link for New Issue on project page (#19172)zeripath2022-03-221-2/+9
| | | | | | | | | Extend issues/new/choose to pass the project id and change New Issue link on project page to use new/choose Fix #19170 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Use `ctx` instead of `db.DefaultContext` in some ↵wxiaoguang2022-03-2218-53/+46
| | | | | | | | | | | | packages(routers/services/modules) (#19163) * Remove `db.DefaultContext` usage in routers, use `ctx` directly * Use `ctx` directly if there is one, remove some `db.DefaultContext` in `services` * Use ctx instead of db.DefaultContext for `cmd` and some `modules` packages * fix incorrect context usage
* Fix the bug: deploy key with write access can not push (#19010)wxiaoguang2022-03-221-1/+0
| | | Use DeployKeyID to replace the IsDeployKey, then CanWriteCode uses the DeployKeyID to check the write permission.
* Renamed ctx.User to ctx.Doer. (#19161)KN4CK3R2022-03-2268-488/+488
| | | | Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Use custom favicon when viewing static files if it exists (#19130)Abheek Dhawan2022-03-191-0/+5
| | | | | Redirect `/favicon.ico` to `/assets/img/favicon.png`. Fix #19109
* Do not send activation email if manual confirm is set (#19119)zeripath2022-03-181-0/+6
| | | | | | | | | | If the mailer is configured then even if Manual confirm is set an activation email is still being sent because `handleUserCreated` is not checking for this case. Fix #17263 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Handle email address not exist. (#19089)KN4CK3R2022-03-151-1/+1
|
* Restrict email address validation (#17688)Lunny Xiao2022-03-143-2/+10
| | | This didn't follow the RFC but it's a subset of that. I think we should narrow the allowed chars at first and discuss more possibility in future PRs.
* Fix lfs bug (#19072)Lunny Xiao2022-03-141-0/+13
| | | * Fix lfs bug
* RSS/Atom support for Repos (#19055)65432022-03-136-64/+85
| | | | | | | * support for repos * refactor * advertise the feeds via meta tags * allow feed suffix and feed header * optimize performance
* Feeds: render markdown to html (#19058)Norwin2022-03-121-2/+23
| | | * feeds: render markdown to html
* Prevent 500 when there is an error during new auth source post (#19041)zeripath2022-03-101-5/+2
| | | | | Fix #19036 Signed-off-by: Andrew Thornton <art27@cantab.net>
* RSS/Atom support for Orgs (#17714)65432022-03-102-29/+29
| | | part of #569
* Add button for issue deletion (#19032)Otto Richter (fnetX)2022-03-092-0/+16
| | | | Co-authored-by: Norwin <noerw@users.noreply.github.com> Co-authored-by: 6543 <6543@obermui.de>
* Fix wrong scopes caused by empty scope input (#19029)wxiaoguang2022-03-081-1/+13
|
* Add config option to disable "Update branch by rebase" (#18745)Jimmy Praet2022-03-041-0/+1
|
* Add note to GPG key response if user has no keys (#18961)KN4CK3R2022-03-021-0/+3
| | | | | | | | | | | * Prevent invalid key response. * Display note instead of 404 response. * Fixed test. Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Refactor admin user filter query parameters (#18965)wxiaoguang2022-03-022-2/+11
| | | | Only pass `status_filter` on admin page Use a more general method to pass query parameters, remove hard-coded keys
* Send 404 on `/{org}.gpg` (#18959)Gusted2022-03-011-1/+9
|
* Accounts with WebAuthn only (no TOTP) now exist ... fix code to handle that ↵65432022-03-021-10/+25
| | | | case (#18897)
* Fix admin user list pagination (#18957)Otto Richter (fnetX)2022-03-011-0/+1
|
* Uncapitalize errors (#18915)Gusted2022-02-263-9/+9
| | | | | - See: https://github.com/golang/go/wiki/CodeReviewComments#error-strings Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* BeforeSourcePath should point to base commit (#18799)Jimmy Praet2022-02-251-2/+2
| | | Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Update assignees check to include any writing team and change org sidebar ↵zeripath2022-02-231-0/+2
| | | | | | | | | | | | (#18680) Following the merging of #17811 teams can now have differing write and readonly permissions, however the assignee list will not include teams which have mixed perms. Further the org sidebar is no longer helpful as it can't describe these mixed permissions situations. Fix #18572 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Lock gofumpt to v0.3.0 and run it (#18866)silverwind2022-02-231-1/+2
| | | | | We can't depend on `latest` version of gofumpt because the output will not be stable across versions. Lock it down to the latest version released yesterday and run it again.
* Don't report signal: killed errors in serviceRPC (#18850)zeripath2022-02-221-1/+3
| | | | | Fix #18849 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Show fullname on issue edits and gpg/ssh signing info (#18827)Wim2022-02-201-1/+9
| | | | | Show missing full names when configured to do so Co-authored-by: zeripath <art27@cantab.net>
* Fix template bug of LFS lock (#18784)Lunny Xiao2022-02-161-0/+1
|
* Fix display time of milestones (#18753)René Schaar2022-02-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | * Fix display time of milestones * Move the SecToTime function From the models/issue_stopwatch.go file to the modules/util package * Rename the sec_to_time file * Updated formatting * Include copyright notice in sec_to_time.go * Apply PR review suggestions - Update copyright notice dates to 2022 - Change `1 day 3h 5min 7s` to `1d 3h 5m 7s` * Rename hrs var and combine conditions * Update unit tests to match new time pattern Changed `1min` to `1m` Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix broken cancel button link on patch page (#18718)Lunny Xiao2022-02-142-3/+3
| | | | | | | | | | * Fix broken cacnel button link on patch page * remove treepath="patch" elsewhere too Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
* Add LDAP group sync to Teams, fixes #1395 (#16299)Sven Seeberg2022-02-111-0/+2
| | | | | | | | | | * Add setting for a JSON that maps LDAP groups to Org Teams. * Add log when removing or adding team members. * Sync is being run on login and periodically. * Existing group filter settings are reused. * Adding and removing team members. * Sync not existing LDAP group. * Login with broken group map JSON.
* Always set PullRequestWorkInProgressPrefixes in PrepareViewPullInfo (#18713)zeripath2022-02-111-2/+2
| | | | | | | | Move setting PullRequestWorkInProgressPrefixes to the start of PrepareViewPullInfo. Fix #18706 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Disable unnecessary OpenID/OAuth2 elements (#18491)Paweł Bogusławski2022-02-091-4/+11
| | | | | | | This mod fixes disabling unnecessary OpenID elements. Related: https://github.com/go-gitea/gitea/pull/13129 Author-Change-Id: IB#1115256
* Add apply-patch, basic revert and cherry-pick functionality (#17902)zeripath2022-02-093-0/+314
| | | | | | | | | | | | | | | This code adds a simple endpoint to apply patches to repositories and branches on gitea. This is then used along with the conflicting checking code in #18004 to provide a basic implementation of cherry-pick revert. Now because the buttons necessary for cherry-pick and revert have required us to create a dropdown next to the Browse Source button I've also implemented Create Branch and Create Tag operations. Fix #3880 Fix #17986 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Added auto-save whitespace behavior if it changed manually (#15566)Viktor Suprun2022-02-081-3/+21
|
* Refactor i18n, use Locale to provide i18n/translation related functions (#18648)wxiaoguang2022-02-082-6/+6
| | | | | | | | * remove unnecessary web context data fields, and unify the i18n/translation related functions to `Locale` * in development, show an error if a translation key is missing * remove the unnecessary loops `for _, lang := range translation.AllLangs()` for every request, which improves the performance slightly * use `ctx.Locale.Language()` instead of `ctx.Data["Lang"].(string)` * add more comments about how the Locale/LangType fields are used
* Delete old git.NewCommand() and use it as git.NewCommandContext() (#18552)65432022-02-062-6/+6
|
* Ensure that blob-excerpt links work for wiki (#18587)zeripath2022-02-052-1/+29
| | | | | | | | It appears that the blob-excerpt links do not work on the wiki - likely since their introduction. This PR adds support for the wiki on these links. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Prevent panic on prohibited user login with oauth2 (#18562)zeripath2022-02-031-1/+1
| | | | | | | | | | | There was an unfortunate regression in #17962 where following detection of the UserProhibitLogin error the err is cast to a pointer by mistake. This causes a panic due to an interface error. Fix #18561 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Collaborator trust model should trust collaborators (#18539)zeripath2022-02-022-2/+2
| | | | | | | | | | * Collaborator trust model should trust collaborators There was an unintended regression in #17917 which leads to only repository admin commits being trusted. This PR restores the old logic. Fix #18501 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add `GetUserTeams` (#18499)Gusted2022-02-011-1/+1
| | | | | | | | | | | | | | | | | | | | * COrrect use `UserID` in `SearchTeams` - Use `UserID` in the `SearchTeams` function, currently it was useless to pass such information. Now it does a INNER statement to `team_user` which obtains UserID -> TeamID data. - Make OrgID optional. - Resolves #18484 * Seperate searching specific user * Add condition back * Use correct struct type Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Fix OAuth Source Edit Page (#18495)zeripath2022-01-312-0/+7
| | | | | | | | * Fix OAuth Source Edit Page to ensure restricted and group settings are set * Also tolerate []interface in the groups Fix #18432 Signed-off-by: Andrew Thornton <art27@cantab.net>