Skip to content

Commit

Permalink
fixes bug in prior merge conflict resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
bmckinney committed Nov 15, 2016
1 parent 3237a62 commit 02a3c30
Showing 1 changed file with 53 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public enum EditMode {
@EJB
ConfirmEmailServiceBean confirmEmailService;
@EJB
SystemConfig systemConfig;
SystemConfig systemConfig;
@EJB
GroupServiceBean groupService;
@Inject
Expand All @@ -107,14 +107,14 @@ public enum EditMode {
MyDataPage mydatapage;
@Inject
PermissionsWrapper permissionsWrapper;

@EJB
AuthenticationServiceBean authSvc;

private AuthenticatedUser currentUser;
private BuiltinUser builtinUser;
private BuiltinUser builtinUser;
private EditMode editMode;
private String redirectPage = "dataverse.xhtml";
private String redirectPage = "dataverse.xhtml";

@NotBlank(message = "Please enter a password for your account.")
private String inputPassword;
Expand All @@ -126,7 +126,7 @@ public enum EditMode {
private int activeIndex;
private String selectTab = "somedata";
UIInput usernameField;

public EditMode getChangePasswordMode () {
return EditMode.CHANGE_PASSWORD;
}
Expand All @@ -146,7 +146,7 @@ public BuiltinUser getBuiltinUser() {
public void setBuiltinUser(BuiltinUser builtinUser) {
this.builtinUser = builtinUser;
}

public EditMode getEditMode() {
return editMode;
}
Expand All @@ -161,7 +161,7 @@ public String getRedirectPage() {

public void setRedirectPage(String redirectPage) {
this.redirectPage = redirectPage;
}
}

public String getInputPassword() {
return inputPassword;
Expand Down Expand Up @@ -245,7 +245,7 @@ public String init() {
editMode = null; // we can't be in create mode for an existing user
}
}

if ( session.getUser().isAuthenticated() ) {
currentUser = (AuthenticatedUser) session.getUser();
notificationsList = userNotificationService.findByUser(((AuthenticatedUser)currentUser).getId());
Expand All @@ -261,8 +261,8 @@ public String init() {
mydatapage.init();
break;
// case "groupsRoles":
// activeIndex = 2;
// break;
// activeIndex = 2;
// break;
case "accountInfo":
activeIndex = 2;
// activeIndex = 3;
Expand All @@ -273,12 +273,12 @@ public String init() {
default:
activeIndex = 0;
break;
}
}

} else {
return permissionsWrapper.notAuthorized();
}

return "";
}

Expand Down Expand Up @@ -313,7 +313,7 @@ public void validateUserName(FacesContext context, UIComponent toValidate, Objec
context.addMessage(toValidate.getClientId(context), message);
}
}

public void validateUserEmail(FacesContext context, UIComponent toValidate, Object value) {
String userEmail = (String) value;
boolean userEmailFound = false;
Expand All @@ -326,7 +326,7 @@ public void validateUserEmail(FacesContext context, UIComponent toValidate, Obje
} else {
//In edit mode...
if (user != null || aUser != null){
userEmailFound = true;
userEmailFound = true;
}
//if there's a match on edit make sure that the email belongs to the
// user doing the editing by checking ids
Expand All @@ -340,7 +340,7 @@ public void validateUserEmail(FacesContext context, UIComponent toValidate, Obje
context.addMessage(toValidate.getClientId(context), message);
}
}


public void validateUserNameEmail(FacesContext context, UIComponent toValidate, Object value) {
String userName = (String) value;
Expand All @@ -362,43 +362,43 @@ public void validateUserNameEmail(FacesContext context, UIComponent toValidate,
}

public void validateCurrentPassword(FacesContext context, UIComponent toValidate, Object value) {

String password = (String) value;

if (StringUtils.isBlank(password)){
logger.log(Level.WARNING, "current password is blank");

((UIInput) toValidate).setValid(false);
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Password Error", "Password is blank: re-type it again.");
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Password Error", "Password is blank: re-type it again.");
context.addMessage(toValidate.getClientId(context), message);
return;

} else {
logger.log(Level.INFO, "current paswword is not blank");
}



if ( ! PasswordEncryption.getVersion(builtinUser.getPasswordEncryptionVersion()).check(password, builtinUser.getEncryptedPassword()) ) {
((UIInput) toValidate).setValid(false);
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Password Error", "Password is incorrect.");
context.addMessage(toValidate.getClientId(context), message);
}
}

public void validateNewPassword(FacesContext context, UIComponent toValidate, Object value) {
String password = (String) value;
if (StringUtils.isBlank(password)){
logger.log(Level.WARNING, "new password is blank");

((UIInput) toValidate).setValid(false);

FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Password Error", "The new password is blank: re-type it again");
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Password Error", "The new password is blank: re-type it again");
context.addMessage(toValidate.getClientId(context), message);
return;

} else {
logger.log(Level.INFO, "new paswword is not blank");
}
Expand All @@ -418,8 +418,8 @@ public void validateNewPassword(FacesContext context, UIComponent toValidate, Ob
context.addMessage(toValidate.getClientId(context), message);
}
}



public void updatePassword(String userName) {
String plainTextPassword = PasswordEncryption.generateRandomPassword();
Expand Down Expand Up @@ -464,15 +464,15 @@ public String save() {
}
session.setUser(au);
userNotificationService.sendNotification(au,
new Timestamp(new Date().getTime()),
UserNotification.Type.CREATEACC, null);
new Timestamp(new Date().getTime()),
UserNotification.Type.CREATEACC, null);

// go back to where user came from
if ("dataverse.xhtml".equals(redirectPage)) {
redirectPage = redirectPage + "&alias=" + dataverseService.findRootDataverse().getAlias();
}
try {

try {
redirectPage = URLDecoder.decode(redirectPage, "UTF-8");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(BuiltinUserPage.class.getName()).log(Level.SEVERE, null, ex);
Expand All @@ -481,9 +481,9 @@ public String save() {

logger.log(Level.FINE, "Sending user to = {0}", redirectPage);

return redirectPage + (!redirectPage.contains("?") ? "?" : "&") + "faces-redirect=true";
return redirectPage + (!redirectPage.contains("?") ? "?" : "&") + "faces-redirect=true";


} else {
String emailBeforeUpdate = currentUser.getEmail();
AuthenticatedUser savedUser = authSvc.updateAuthenticatedUser(currentUser, builtinUser.getDisplayInfo());
Expand Down Expand Up @@ -513,7 +513,7 @@ public String save() {
} else {
JsfHelper.addFlashMessage(msg);
}
return null;
return null;
}
}

Expand Down Expand Up @@ -551,7 +551,7 @@ public void onTabChange(TabChangeEvent event) {
mydatapage.init();
}
}

private String getRoleStringFromUser(AuthenticatedUser au, DvObject dvObj) {
// Find user's role(s) for given dataverse/dataset
Set<RoleAssignment> roles = permissionService.assignmentsFor(au, dvObj);
Expand All @@ -575,7 +575,7 @@ private String getRoleStringFromUser(AuthenticatedUser au, DvObject dvObj) {
public void displayNotification() {
for (UserNotification userNotification : notificationsList) {
switch (userNotification.getType()) {
case ASSIGNROLE:
case ASSIGNROLE:
case REVOKEROLE:
// Can either be a dataverse or dataset, so search both
Dataverse dataverse = dataverseService.find(userNotification.getObjectId());
Expand All @@ -597,7 +597,7 @@ public void displayNotification() {
case CREATEDV:
userNotification.setTheObject(dataverseService.find(userNotification.getObjectId()));
break;

case REQUESTFILEACCESS:
DataFile file = fileService.find(userNotification.getObjectId());
userNotification.setTheObject(file.getOwner());
Expand All @@ -606,7 +606,7 @@ public void displayNotification() {
case REJECTFILEACCESS:
userNotification.setTheObject(datasetService.find(userNotification.getObjectId()));
break;

case MAPLAYERUPDATED:
case CREATEDS:
case SUBMITTEDDS:
Expand All @@ -617,6 +617,7 @@ public void displayNotification() {

case CREATEACC:
userNotification.setTheObject(userNotification.getUser());
break;

case CHECKSUMFAIL:
userNotification.setTheObject(datasetService.find(userNotification.getObjectId()));
Expand All @@ -628,7 +629,7 @@ public void displayNotification() {

case CHECKSUMIMPORT:
userNotification.setTheObject(datasetVersionService.find(userNotification.getObjectId()));
break;
break;
}

userNotification.setDisplayAsRead(userNotification.isReadNotification());
Expand All @@ -638,12 +639,12 @@ public void displayNotification() {
}
}
}

public void sendConfirmEmail() {
logger.fine("called sendConfirmEmail()");
String userEmail = currentUser.getEmail();
ConfirmEmailUtil confirmEmailUtil = new ConfirmEmailUtil();

try {
confirmEmailService.beginConfirm(currentUser);
List<String> args = Arrays.asList(
Expand All @@ -654,7 +655,7 @@ public void sendConfirmEmail() {
Logger.getLogger(BuiltinUserPage.class.getName()).log(Level.SEVERE, null, ex);
}
}

public boolean showVerifyEmailButton() {
/**
* Determines whether the button to send a verification email appears on user page
Expand All @@ -669,20 +670,20 @@ public boolean showVerifyEmailButton() {
public boolean isEmailIsVerified() {
if (currentUser.getEmailConfirmed() != null && confirmEmailService.findSingleConfirmEmailDataByUser(currentUser) == null) {
return true;
} else return false;
} else return false;
}

public boolean isEmailNotVerified() {
if (currentUser.getEmailConfirmed() == null || confirmEmailService.findSingleConfirmEmailDataByUser(currentUser) != null) {
return true;
} else return false;
}

public boolean isEmailGrandfathered() {
ConfirmEmailUtil confirmEmailUtil = new ConfirmEmailUtil();
if (currentUser.getEmailConfirmed() == confirmEmailUtil.getGrandfatheredTime()) {
return true;
} else return false;
}

}
}

0 comments on commit 02a3c30

Please sign in to comment.