From 619291b080176f65b85fe9ca4d0df56cb9ad8393 Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 11 Dec 2013 10:29:25 -0500 Subject: [PATCH] Fix NPE on usermodel account type checking Change-Id: I964381a896e8c8bf8cce5f19a83fd7c33ef5c9bd --- src/main/java/com/gitblit/ConfigUserService.java | 2 +- src/main/java/com/gitblit/models/UserModel.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gitblit/ConfigUserService.java b/src/main/java/com/gitblit/ConfigUserService.java index aae7c14c..c1f0506d 100644 --- a/src/main/java/com/gitblit/ConfigUserService.java +++ b/src/main/java/com/gitblit/ConfigUserService.java @@ -859,7 +859,7 @@ public class ConfigUserService implements IUserService { user.emailAddress = config.getString(USER, username, EMAILADDRESS); user.accountType = AccountType.fromString(config.getString(USER, username, ACCOUNTTYPE)); if (Constants.EXTERNAL_ACCOUNT.equals(user.password) && user.accountType.isLocal()) { - user.accountType = null; + user.accountType = AccountType.EXTERNAL; } user.organizationalUnit = config.getString(USER, username, ORGANIZATIONALUNIT); user.organization = config.getString(USER, username, ORGANIZATION); diff --git a/src/main/java/com/gitblit/models/UserModel.java b/src/main/java/com/gitblit/models/UserModel.java index 6e8de402..3c33bd32 100644 --- a/src/main/java/com/gitblit/models/UserModel.java +++ b/src/main/java/com/gitblit/models/UserModel.java @@ -95,7 +95,9 @@ public class UserModel implements Principal, Serializable, Comparable } public boolean isLocalAccount() { - return !Constants.EXTERNAL_ACCOUNT.equals(password) || accountType.isLocal(); + return !Constants.EXTERNAL_ACCOUNT.equals(password) + || accountType == null + || accountType.isLocal(); } /** -- 2.39.5