Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add realm.loginedUserDefaultTeam #1250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main/distrib/data/defaults.properties
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,13 @@ web.tabLength = 4
# BASEFOLDER
realm.userService = ${baseFolder}/users.conf


# if not empty, then every logined user will join this team
# so we can set acl on the default team
# SINCE 1.8.2
realm.loginedUserDefaultTeam=


# Ordered list of external authentication providers which will be used if
# authentication against the local user service fails.
#
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/gitblit/auth/AuthenticationProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.gitblit.Constants.Role;
import com.gitblit.Constants.AuthenticationType;
import com.gitblit.IStoredSettings;
import com.gitblit.Keys;
import com.gitblit.manager.IRuntimeManager;
import com.gitblit.manager.IUserManager;
import com.gitblit.models.TeamModel;
Expand Down Expand Up @@ -88,17 +89,27 @@ protected void setCookie(UserModel user) {
protected void updateUser(UserModel userModel) {
final UserModel userLocalDB = userManager.getUserModel(userModel.getName());

String loginedUserDefaultTeam = settings.getString(Keys.realm.loginedUserDefaultTeam,null);
if(!StringUtils.isEmpty(loginedUserDefaultTeam)){
TeamModel defaultTeam = userManager.getTeamModel(loginedUserDefaultTeam);
if( defaultTeam != null ) {
userModel.teams.add(defaultTeam);
}
}
// Establish the checksum of the current version of the user
final BigInteger userCurrentCheck = DeepCopier.checksum(userModel);

// Establish the checksum of the stored version of the user
final BigInteger userLocalDBcheck = DeepCopier.checksum(userLocalDB);


// Compare the checksums
if (!userCurrentCheck.equals(userLocalDBcheck)) {
// If mismatch, save the new instance.
userManager.updateUserModel(userModel);
}


}

protected void updateTeam(TeamModel teamModel) {
Expand Down