summaryrefslogtreecommitdiffstats
path: root/models/user.go
Commit message (Collapse)AuthorAgeFilesLines
* Add Password Algorithm option to install page (#14701)zeripath2021-02-161-0/+10
| | | | | | | Add Password Algorithm option to install page Fix #14674 Co-authored-by: John Olheiser <john.olheiser@gmail.com>
* Fix gpg key deletion (#14561)Anton Khimich2021-02-041-0/+10
| | | | | | | | | | | | | | | | | | | * Fix GPG key deletion when user is deleted Per #14531, deleting a user account will delete the user's GPG keys from the `gpg_key` table but not from `gpg_key_import`, which causes an error when creating an account with the same email and attempting to re-add the same key. This commit deletes all entries from `gpg_key_import` that match any GPG key IDs belonging to the user. * Format added code in models/user.go * Create a new function for listing GPG keys and apply it Create a new function `listGPGKeys` and replace a previous use of `ListGPGKeys`. Thanks to @6543 for the patch. Co-authored-by: Anton Khimich <anton.khimicha@mail.utoronto.ca> Co-authored-by: 6543 <6543@obermui.de>
* Redirect on changed user and org name (#11649)Andrew Bezold2021-01-241-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add redirect for user * Add redirect for orgs * Add user redirect test * Appease linter * Add comment to DeleteUserRedirect function * Fix locale changes * Fix GetUserByParams * Fix orgAssignment * Remove debug logging * Add redirect prompt * Dont Export DeleteUserRedirect & only use it within a session * Unexport newUserRedirect * cleanup * Fix & Dedub API code * Format Template * Add Migration & rm dublicat * Refactor: unexport newRepoRedirect() & rm dedub del exec * if this fails we'll need to re-rename the user directory Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Enhance Ghost comment mitigation Settings (#14392)65432021-01-211-14/+33
| | | | | | | | | | | | | | | | | | | | | | | | | * refactor models.DeleteComment and delete related reactions too * use deleteComment for UserDeleteWithCommentsMaxDays in DeleteUser * nits * Use time.Duration as other time settings have * docs * Resolve Fixme & fix potential deadlock * Disabled by Default * Update Config Value Description * switch args * Update models/issue_comment.go Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
* Implement ghost comment mitigation (#14349)65432021-01-171-1/+11
| | | | | | | | | | | | | * Implement ghost comment mitigation Adds a config option USER_DELETE_WITH_COMMENTS_MAX_DAYS to the [service] section. See https://codeberg.org/Codeberg/Discussion/issues/24 for the underlying issue. * cleanup * use setting module correctly * add to docs Co-authored-by: Moritz Marquardt <git@momar.de>
* Issues overview should not show issues from archived repos (#13220)Elena Neuschild2021-01-121-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add lots of comments to user.Issues() * Answered some questions from comments * fix typo in comment * Refac user.Issues(): add func repoIDs * Refac user.Issues(): add func userRepoIDs * Refac user.Issues(): add func issueIDsFromSearch * Refac user.Issues(): improve error handling * Refac user.Issues(): add inline documentation and move variable declarations closer to their usages * Refac user.Issues(): add func repoIDMap * Refac user.Issues(): cleanup * Refac: Separate Issues from Pulls during routing * fix typo in comment * Adapt Unittests to Refactoring * Issue13171: Issue and PR Overviews now ignore archived Repositories * changed some verbatim SQL conditions to builder.Eq * models/issue.go: use OptionalBool properly Co-authored-by: 6543 <6543@obermui.de> * Use IsArchived rather than ExcludeArchivedRepos * fixed broken test after merge * added nil check * Added Unit Test securing Issue 13171 fix * Improved IsArchived filtering in issue.GetUserIssueStats * Removed unused func * Added grouping to avoid returning duplicate repo IDs Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Gitea <gitea@fake.local> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* [Refactor] Passwort Hash/Set (#14282)65432021-01-101-5/+17
| | | | | | | | | * move SaltGeneration into HashPasswort and rename it to what it does * Migration: Where Password is Valid with Empty String delete it * prohibit empty password hash * let SetPassword("") unset pwd stuff
* Add option to change username to the admin panel (#14229)65432021-01-101-7/+7
| | | | | Co-authored-by: Bwko <bouwko@gmail.com> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: zeripath <art27@cantab.net>
* migrate from com.* to alternatives (#14103)65432020-12-251-4/+3
| | | | | | | | | | | | | | | * remove github.com/unknwon/com from models * dont use "com.ToStr()" * replace "com.ToStr" with "fmt.Sprint" where its easy to do * more refactor * fix test * just "proxy" Copy func for now * as per @lunny
* Accept multiple SSH keys in single LDAP SSHPublicKey attribute (#13989)zeripath2020-12-181-8/+22
| | | | | | | | * Accept multiple SSH keys in single LDAP SSHPublicKey attribute Fix #13984 Signed-off-by: Andrew Thornton <art27@cantab.net>
* HotFix: Hide private partisipation in Orgs (#13994)65432020-12-171-0/+1
| | | | | * HotFix: Hide private partisipation in Orgs * refactor & add node to fuc GetOrganizations
* skip email validation on empty string (#13627)65432020-11-201-11/+16
| | | | - move validation into its own function - use a session for UpdateUserSetting
* Add email validity check (#13475)Chris Shyi2020-11-141-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Improve error feedback for duplicate deploy keys Instead of a generic HTTP 500 error page, a flash message is rendered with the deploy key page template so inform the user that a key with the intended title already exists. * API returns 422 error when key with name exists * Add email validity checking Add email validity checking for the following routes: [Web interface] 1. User registration 2. User creation by admin 3. Adding an email through user settings [API] 1. POST /admin/users 2. PATCH /admin/users/:username 3. POST /user/emails * Add further tests * Add signup email tests * Add email validity check for linking existing account * Address PR comments * Remove unneeded DB session * Move email check to updateUser Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Avatar autogeneration fixed (#13233)Paweł Bogusławski2020-10-231-4/+0
| | | | | | | | This mod fixes problem with initial avatar autogeneration and avatar autogneration after deleting previous avatar. Related: https://github.com/go-gitea/gitea/issues/13159 Fixes: 80a6b0f5bce15a641fc75f5f1ef6e42ef54424bc Author-Change-Id: IB#1105243
* [Refactor] Move APIFormat functions into convert package (#12856)65432020-10-171-19/+0
| | | | | | | | | | | | | | | | | | | | | | | * USER APIFormat -> ToUser * Migrate more and mark APIFormat deprecated * models.Comment APIFormat() -> convert.ToComment * models.Release APIFormat() -> convert.ToRelease * models.Attachments APIFormat() -> convert.ToReleaseAttachments * models.CommitStatus APIFormat() -> convert.ToCommitStatus * finish migration to convert.ToUser * Move Test * Imprufe Test * fix test Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Improve users management through the CLI (#6001) (#10492)ydelafollye2020-10-151-0/+6
| | | | | | | | | | * Fix images in wiki edit preview (#11546) Make sure wiki editor sets wiki to true so gitea renders it as a wiki page. Also change the context data attr for edit form. This looks wrong but everywhere else in our code assumes the urlPrefix to be just the repo url when rendering and manually adds /wiki to the rendered url regardless. Fixes #11540
* Avatars and Repo avatars support storing in minio (#12516)Lunny Xiao2020-10-141-166/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Avatar support minio * Support repo avatar minio storage * Add missing migration * Fix bug * Fix test * Add test for minio store type on avatars and repo avatars; Add documents * Fix bug * Fix bug * Add back missed avatar link method * refactor codes * Simplify the codes * Code improvements * Fix lint * Fix test mysql * Fix test mysql * Fix test mysql * Fix settings * Fix test * fix test * Fix bug
* Add ssh certificate support (#12281)Wim2020-10-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add ssh certificate support * Add ssh certificate support to builtin ssh * Write trusted-user-ca-keys.pem based on configuration * Update app.example.ini * Update templates/user/settings/keys_principal.tmpl Co-authored-by: silverwind <me@silverwind.io> * Remove unused locale string * Update options/locale/locale_en-US.ini Co-authored-by: silverwind <me@silverwind.io> * Update options/locale/locale_en-US.ini Co-authored-by: silverwind <me@silverwind.io> * Update models/ssh_key.go Co-authored-by: silverwind <me@silverwind.io> * Add missing creation of SSH.Rootpath * Update cheatsheet, example and locale strings * Update models/ssh_key.go Co-authored-by: zeripath <art27@cantab.net> * Update models/ssh_key.go Co-authored-by: zeripath <art27@cantab.net> * Update models/ssh_key.go Co-authored-by: zeripath <art27@cantab.net> * Update models/ssh_key.go Co-authored-by: zeripath <art27@cantab.net> * Update models/ssh_key.go * Optimizations based on feedback * Validate CA keys for external sshd * Add filename option and change default filename Add a SSH_TRUSTED_USER_CA_KEYS_FILENAME option which default is RUN_USER/.ssh/gitea-trusted-user-ca-keys.pem Do not write a file when SSH_TRUSTED_USER_CA_KEYS is empty. Add some more documentation. * Remove unneeded principalkey functions * Add blank line * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * Add SSH_AUTHORIZED_PRINCIPALS_ALLOW option This adds a SSH_AUTHORIZED_PRINCIPALS_ALLOW which is default email,username this means that users only can add the principals that match their email or username. To allow anything the admin need to set the option anything. This allows for a safe default in gitea which protects against malicious users using other user's prinicipals. (before that user could set it). This commit also has some small other fixes from the last code review. * Rewrite principal keys file on user deletion * Use correct rewrite method * Set correct AuthorizedPrincipalsBackup default setting * Rewrite principalsfile when adding principals * Add update authorized_principals option to admin dashboard * Handle non-primary emails Signed-off-by: Andrew Thornton <art27@cantab.net> * Add the command actually to the dashboard template * Update models/ssh_key.go Co-authored-by: silverwind <me@silverwind.io> * By default do not show principal options unless there are CA keys set or they are explicitly set Signed-off-by: Andrew Thornton <art27@cantab.net> * allow settings when enabled * Fix typos in TrustedUserCAKeys path * Allow every CASignatureAlgorithms algorithm As this depends on the content of TrustedUserCAKeys we should allow all signature algorithms as admins can choose the specific algorithm on their signing CA * Update models/ssh_key.go Co-authored-by: Lauris BH <lauris@nix.lv> * Fix linting issue Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Refactor use TrimSuffix instead of TrimRight (#12993)65432020-10-011-1/+1
| | | | | | | * Refactor use TrimSuffix instead of TrimRight * TrimRight right * has #12990
* Adopt repositories (#12920)zeripath2020-09-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Don't automatically delete repository files if they are present Prior to this PR Gitea would delete any repository files if they are present during creation or migration. This can in certain circumstances lead to data-loss and is slightly unpleasant. This PR provides a mechanism for Gitea to adopt repositories on creation and otherwise requires an explicit flag for deletion. PushCreate is slightly different - the create will cause adoption if that is allowed otherwise it will delete the data if that is allowed. Signed-off-by: Andrew Thornton <art27@cantab.net> * Update swagger Signed-off-by: Andrew Thornton <art27@cantab.net> * Fix tests and migrate overwrite Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @lunny Only offer to adopt or overwrite if the user can do that. Allow the site administrator to adopt or overwrite in all circumstances Signed-off-by: Andrew Thornton <art27@cantab.net> * Use setting.Repository.DefaultBranch for the default branch Signed-off-by: Andrew Thornton <art27@cantab.net> * Always set setting.Repository.DefaultBranch Signed-off-by: Andrew Thornton <art27@cantab.net> * update swagger Signed-off-by: Andrew Thornton <art27@cantab.net> * update templates Signed-off-by: Andrew Thornton <art27@cantab.net> * ensure repo closed Signed-off-by: Andrew Thornton <art27@cantab.net> * Rewrite of adoption as per @6543 and @lunny Signed-off-by: Andrew Thornton <art27@cantab.net> * Apply suggestions from code review * update swagger Signed-off-by: Andrew Thornton <art27@cantab.net> * missing not Signed-off-by: Andrew Thornton <art27@cantab.net> * add modals and flash reporting Signed-off-by: Andrew Thornton <art27@cantab.net> * Make the unadopted page searchable Signed-off-by: Andrew Thornton <art27@cantab.net> * Add API Signed-off-by: Andrew Thornton <art27@cantab.net> * Fix swagger Signed-off-by: Andrew Thornton <art27@cantab.net> * fix swagger Signed-off-by: Andrew Thornton <art27@cantab.net> * Handle empty and non-master branched repositories Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * remove commented out code Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Fix "only mail on mention" bug (#12775)赵智超2020-09-091-1/+11
| | | | | | | | | | | * fix mail mention bug fix #12774 Signed-off-by: a1012112796 <1012112796@qq.com> * fix test Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Use argon as default password hash algorithm (#12688)zeripath2020-09-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * Restrict TLS connections to 1.2 minimum * Set Argon2 as the default KDF * Fix user.yml * Remove TLS minversion changes Signed-off-by: Andrew Thornton <art27@cantab.net> * Add migration as per @techknowlogick Signed-off-by: Andrew Thornton <art27@cantab.net> * set the password algo in the fixtures Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove the v148 migration - it needs recreate table to change the defaults Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Nadim Kobeissi <nadim@symbolic.software>
* Fix bug preventing transfer to private organization (#12497)zeripath2020-08-161-4/+4
| | | | | | | | | | | | | | | | | * Fix bug preventing transfer to private organization The code assessing whether a private organization was visible to a user before allowing transfer was incorrect due to testing membership the wrong way round This PR fixes this issue and renames the function performing the test to be clearer. Further looking at the API for transfer repository - no testing was performed to ensure that the acting user could actually see the new owning organization. Signed-off-by: Andrew Thornton <art27@cantab.net> * change IsUserPartOfOrg everywhere
* Re-attempt to delete temporary upload if the file is locked by another ↵zeripath2020-08-111-3/+3
| | | | | | | | | | | process (#12447) Replace all calls to os.Remove/os.RemoveAll by retrying util.Remove/util.RemoveAll and remove circular dependencies from util. Fix #12339 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io>
* Add serviceworker.js to KnownPublicEntries (#11992)silverwind2020-06-201-7/+4
| | | | | | | Fixes a wrong 302 redirect to the login page, see https://github.com/go-gitea/gitea/issues/11989. Also made it so the reserved username list is extended with those known entries so we avoid code duplication. Should be backported to 1.12.
* Use ID or Where to instead directly use Get when load object from database ↵Lunny Xiao2020-06-171-2/+2
| | | | | | | | | | | | (#11925) * Use ID or Where to instead directly use Get when load object from database * Apply suggestions from code review Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
* Rework api/user/repos for pagination (#11827)Cirno the Strongest2020-06-131-1/+1
| | | | | | | | | | | | | | * Add count to `GetUserRepositories` so that pagination can be supported for `/user/{username}/repos` * Rework ListMyRepos to use models.SearchRepository ListMyRepos was an odd one. It first fetched all user repositories and then tried to supplement them with accessible map. The end result was that: * Limit for pagination did not work because accessible repos would always be appended * The amount of pages was incorrect if one were to calculate it * When paginating, all accessible repos would be shown on every page Hopefully it should now work properly. Fixes #11800 and does not require any change on Drone-side as it can properly interpret and act on Link header which we now set. Co-authored-by: Lauris BH <lauris@nix.lv>
* Add hide activity option (#11353)l-jonas2020-06-051-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | * Add hide activity option This closes https://github.com/go-gitea/gitea/issues/7927 * Adjust for linter * Adjust for linter * Add tests * Remove info that admins can view the activity * Adjust new tests for linter * Rename v139.go to v140.go * Rename v140.go to v141.go * properly indent * gofmt Co-authored-by: Jonas Lochmann <git@inkompetenz.org> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Refactor Cron and merge dashboard tasks (#10745)zeripath2020-05-161-19/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor Cron and merge dashboard tasks * Merge Cron and Dashboard tasks * Make every cron task report a system notice on completion * Refactor the creation of these tasks * Ensure that execution counts of tasks is correct * Allow cron tasks to be started from the cron page * golangci-lint fixes * Enforce that only one task with the same name can be registered Signed-off-by: Andrew Thornton <art27@cantab.net> * fix name check Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @guillep2k * as per @lafriks Signed-off-by: Andrew Thornton <art27@cantab.net> * Add git.CommandContext variants Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Correctly set the organization num repos (#11339)zeripath2020-05-121-7/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Correctly set the organization num repos Correctly set the organization num repos to the number of accessible repos for the user Fix #11194 Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @lunny Signed-off-by: Andrew Thornton <art27@cantab.net> * attempt to fix mssql Signed-off-by: Andrew Thornton <art27@cantab.net> * Update models/user.go * Explicit columns Signed-off-by: Andrew Thornton <art27@cantab.net> * Add test and fix 0 counted orgs Signed-off-by: Andrew Thornton <art27@cantab.net> * remove orgname from api Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix creation of Organization repos by Users with max created personal repos ↵Andrew Bezold2020-04-301-0/+1
| | | | | | | | | | | | | | | | | (#11183) * Fix creation of Org repos Fix go-gitea#9269 * Change variable name to appease linter * Update PR with suggestions Add a note for user.CanCreateRepo() about failure assumptions Change repo.create help message Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
* Send 404 immediately for known public requests (#11117)silverwind2020-04-181-7/+8
| | | | | | | Instead of further handling requests to public which causes issues like #11088, immediately terminate requests to directories js, css, fomantic if no file is found which is checked against a hardcoded list. Maybe there is a way to retrieve the top-level entries below public in a dynamic fashion. I also added fomantic to the reserved usernames and sorted the list. Fixes: #11088
* Add restricted user filter to LDAP authentication (#10600)Lauris BH2020-03-051-10/+16
| | | | | | * Add restricted user filter to LDAP authentification * Fix unit test cases
* Remove Unused Functions (#10516)65432020-03-021-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | * remove ReplaceLeft * remove GetRepositoryByOwnerAndName chainload to models.GetRepositoryByOwnerAndName * remove CheckUnitUser chainload to models.CheckUnitUser * remove MakeAssigneeList * remove DownloadDiff & DownloadPatch -> DownloadDiffOrPatch * remove GetRandomBytesAsBase64 * remove PushUpdateDeleteTags * remove GetUserByKeyID (you still can resolve user by "k, err := GetPublicKeyByID; userID := k.OwnerID") * remove BasicAuthEncode from struct package -> same function in modules/base/tools ! * remove UserID from api.utils * remove unused func from structs package
* Show the username as a fallback on feeds if full name is blank (#10438)James Lakin2020-02-261-3/+5
| | | | | Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
* Code Refactor of IssueWatch related things (#10401)65432020-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * refactor * optimize * remove Iretating function LoadWatchUsers do not load Users into IW object and it is used only in api ... so move this logic * remove unessesary * Apply suggestions from code review Thx Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * make Tests more robust * fix rebase * restart CI * CI no dont hit sqlites deadlock Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
* Various fixes in login sources (#10428)guillep2k2020-02-231-0/+9
|
* Ensure only own addresses are updated (#10397)guillep2k2020-02-211-1/+1
|
* Blacklist manifest.json & milestones user (#10292)techknowlogick2020-02-161-0/+2
| | | Fix #10290
* Add API branch protection endpoint (#9311)David Svantesson2020-02-121-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * add API branch protection endpoint * lint * Change to use team names instead of ids. * Status codes. * fix * Fix * Add new branch protection options (BlockOnRejectedReviews, DismissStaleApprovals, RequireSignedCommits) * Do xorm query directly * fix xorm GetUserNamesByIDs * Add some tests * Improved GetTeamNamesByID * http status created for CreateBranchProtection * Correct status code in integration test Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* [API] Fix inconsistent label color format (#10129)65432020-02-091-1/+1
| | | | | | | | | | | | | | | | * update and use labelColorPattern * add TestCases * fix lint * # optional for templates * fix typo * some more * fix lint of **master**
* Fix invalid repo urls after change username (#10150)mavenbline2020-02-081-1/+11
| | | | | | | | | * Fix invalid repo urls after change username * Update user.go Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
* Ensure DeleteUser is not allowed to Delete Orgs and visa versa (#10134)65432020-02-041-0/+4
| | | | | | | | | | | | | | * add check to DeleteUser * add check to DeleteOrganization * add Test * remove redundancy (deleteOrg is only used in DeleteOrganization) * Update models/org.go Co-authored-by: zeripath <art27@cantab.net>
* Move PushUpdateAddDeleteTags to repository module from models (#10106)Lunny Xiao2020-02-031-4/+9
| | | | | | * Move PushUpdateAddDeleteTags to repository module from models * Fix deadlock on sqlite
* [BugFix] [API] Pull.API.Convert: Only try to get HeadBranch if HeadRepo ↵65432020-01-311-0/+3
| | | | | | | | | | | | | | exist (#10029) * only try to get HeadBranch if HeadRepo exist * impruve * no nil error * add TEST * correct error msg
* API add/generalize pagination (#9452)SpaWn2KiLl2020-01-241-38/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * paginate results * fixed deadlock * prevented breaking change * updated swagger * go fmt * fixed find topic * go mod tidy * go mod vendor with go1.13.5 * fixed repo find topics * fixed unit test * added Limit method to Engine struct; use engine variable when provided; fixed gitignore * use ItemsPerPage for default pagesize; fix GetWatchers, getOrgUsersByOrgID and GetStargazers; fix GetAllCommits headers; reverted some changed behaviors * set Page value on Home route * improved memory allocations * fixed response headers * removed logfiles * fixed import order * import order * improved swagger * added function to get models.ListOptions from context * removed pagesize diff on unit test * fixed imports * removed unnecessary struct field * fixed go fmt * scoped PR * code improvements * code improvements * go mod tidy * fixed import order * fixed commit statuses session * fixed files headers * fixed headers; added pagination for notifications * go mod tidy * go fmt * removed Private from user search options; added setting.UI.IssuePagingNum as default valeu on repo's issues list * Apply suggestions from code review Co-Authored-By: 6543 <6543@obermui.de> Co-Authored-By: zeripath <art27@cantab.net> * fixed build error * CI.restart() * fixed merge conflicts resolve * fixed conflicts resolve * improved FindTrackedTimesOptions.ToOptions() method * added backwards compatibility on ListReleases request; fixed issue tracked time ToSession * fixed build error; fixed swagger template * fixed swagger template * fixed ListReleases backwards compatibility * added page to user search route Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
* Add option to prevent LDAP from deactivating everything on empty search (#9879)zeripath2020-01-201-0/+9
| | | | | | | | | | | * Add option to prevent LDAP from deactivating everything on empty search * Update options/locale/locale_en-US.ini Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Add setting to set default and global disabled repository units. (#8788)David Svantesson2020-01-171-0/+3
| | | | | | | | | | | | | | | | | | * Add possibility to global disable repo units. * Add Default Repo Unit app.ini setting. * Hide units * Hide disabled repo units * Minor fixes * Indicate disabled units in team settings. Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* Migrate reactions when migrating repository from github (#9599)Lunny Xiao2020-01-151-0/+9
| | | | | | | | | | | | | | | | | | | | * Migrate reactions when migrating repository from github * fix missed sleep * fix tests * update reactions when external user binding * Fix test * fix tests * change the copy head * fix test * fix migrator add/delete reaction
* Restricted users (#6274)Manush Dodunekov2020-01-131-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Restricted users (#4334): initial implementation * Add User.IsRestricted & UI to edit it * Pass user object instead of user id to places where IsRestricted flag matters * Restricted users: maintain access rows for all referenced repos (incl public) * Take logged in user & IsRestricted flag into account in org/repo listings, searches and accesses * Add basic repo access tests for restricted users Signed-off-by: Manush Dodunekov <manush@stendahls.se> * Mention restricted users in the faq Signed-off-by: Manush Dodunekov <manush@stendahls.se> * Revert unnecessary change `.isUserPartOfOrg` -> `.IsUserPartOfOrg` Signed-off-by: Manush Dodunekov <manush@stendahls.se> * Remove unnecessary `org.IsOrganization()` call Signed-off-by: Manush Dodunekov <manush@stendahls.se> * Revert to an `int64` keyed `accessMap` * Add type `userAccess` * Add convenience func updateUserAccess() * Turn accessMap into a `map[int64]userAccess` Signed-off-by: Manush Dodunekov <manush@stendahls.se> * or even better: `map[int64]*userAccess` * updateUserAccess(): use tighter syntax as suggested by lafriks * even tighter * Avoid extra loop * Don't disclose limited orgs to unauthenticated users * Don't assume block only applies to orgs * Use an array of `VisibleType` for filtering * fix yet another thinko * Ok - no need for u * Revert "Ok - no need for u" This reverts commit 5c3e886aabd5acd997a3b35687d322439732c200. Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com> Co-authored-by: Lauris BH <lauris@nix.lv>