Add Visible modes function from Organisation to Users too (#16069)
You can limit or hide organisations. This pull make it also posible for users - new strings to translte - add checkbox to user profile form - add checkbox to admin user.edit form - filter explore page user search - filter api admin and public user searches - allow admins view "hidden" users - add app option DEFAULT_USER_VISIBILITY - rewrite many files to use Visibility field - check for teams intersection - fix context output - right fake 404 if not visible Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
		
					parent
					
						
							
								19ac575d57
							
						
					
				
			
			
				commit
				
					
						22a0636544
					
				
			
		
					 32 changed files with 440 additions and 68 deletions
				
			
		| 
						 | 
				
			
			@ -66,6 +66,7 @@ func CreateUser(ctx *context.APIContext) {
 | 
			
		|||
	//   "422":
 | 
			
		||||
	//     "$ref": "#/responses/validationError"
 | 
			
		||||
	form := web.GetForm(ctx).(*api.CreateUserOption)
 | 
			
		||||
 | 
			
		||||
	u := &models.User{
 | 
			
		||||
		Name:               form.Username,
 | 
			
		||||
		FullName:           form.FullName,
 | 
			
		||||
| 
						 | 
				
			
			@ -97,7 +98,15 @@ func CreateUser(ctx *context.APIContext) {
 | 
			
		|||
		ctx.Error(http.StatusBadRequest, "PasswordPwned", errors.New("PasswordPwned"))
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if err := models.CreateUser(u); err != nil {
 | 
			
		||||
 | 
			
		||||
	var overwriteDefault *models.CreateUserOverwriteOptions
 | 
			
		||||
	if form.Visibility != "" {
 | 
			
		||||
		overwriteDefault = &models.CreateUserOverwriteOptions{
 | 
			
		||||
			Visibility: api.VisibilityModes[form.Visibility],
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := models.CreateUser(u, overwriteDefault); err != nil {
 | 
			
		||||
		if models.IsErrUserAlreadyExist(err) ||
 | 
			
		||||
			models.IsErrEmailAlreadyUsed(err) ||
 | 
			
		||||
			models.IsErrNameReserved(err) ||
 | 
			
		||||
| 
						 | 
				
			
			@ -209,6 +218,9 @@ func EditUser(ctx *context.APIContext) {
 | 
			
		|||
	if form.Active != nil {
 | 
			
		||||
		u.IsActive = *form.Active
 | 
			
		||||
	}
 | 
			
		||||
	if len(form.Visibility) != 0 {
 | 
			
		||||
		u.Visibility = api.VisibilityModes[form.Visibility]
 | 
			
		||||
	}
 | 
			
		||||
	if form.Admin != nil {
 | 
			
		||||
		u.IsAdmin = *form.Admin
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -395,6 +407,7 @@ func GetAllUsers(ctx *context.APIContext) {
 | 
			
		|||
	listOptions := utils.GetListOptions(ctx)
 | 
			
		||||
 | 
			
		||||
	users, maxResults, err := models.SearchUsers(&models.SearchUserOptions{
 | 
			
		||||
		Actor:       ctx.User,
 | 
			
		||||
		Type:        models.UserTypeIndividual,
 | 
			
		||||
		OrderBy:     models.SearchOrderByAlphabetically,
 | 
			
		||||
		ListOptions: listOptions,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue