fix(login): Fix login error when corp user editable information is not present. Fixes #1948 (#1950)

* fix(login): Fix login error when corp user editable information is not present

Check if the aspects are present before extracting the values

* More stronger checks for presence of aspects in model
This commit is contained in:
Nagarjuna Kanamarlapudi 2020-10-21 20:21:34 -07:00 committed by GitHub
parent c29fd38c7f
commit e936e2b856
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,9 +5,8 @@ import com.linkedin.datahub.models.table.CompanyUser;
import com.linkedin.datahub.models.table.User; import com.linkedin.datahub.models.table.User;
import com.linkedin.datahub.models.table.UserEntity; import com.linkedin.datahub.models.table.UserEntity;
import com.linkedin.identity.CorpUser; import com.linkedin.identity.CorpUser;
import javax.annotation.Nonnull;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import javax.annotation.Nonnull;
public class CorpUserUtil { public class CorpUserUtil {
@ -33,10 +32,14 @@ public class CorpUserUtil {
@Nonnull @Nonnull
public static User toCorpUserView(CorpUser corpUser) { public static User toCorpUserView(CorpUser corpUser) {
User user = new User(); User user = new User();
user.setEmail(corpUser.getInfo().getEmail());
user.setName(corpUser.getInfo().getFullName());
user.setUserName(corpUser.getUsername()); user.setUserName(corpUser.getUsername());
user.setPictureLink(corpUser.getEditableInfo().getPictureLink().toString()); if (corpUser.getInfo() != null) {
user.setEmail(corpUser.getInfo().getEmail());
user.setName(corpUser.getInfo().getFullName());
}
if (corpUser.getEditableInfo() != null) {
user.setPictureLink(corpUser.getEditableInfo().getPictureLink().toString());
}
return user; return user;
} }