Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v1.1.0-enhancements' into v1.1.0…
Browse files Browse the repository at this point in the history
…-enhancements
  • Loading branch information
espinoj committed Jan 5, 2016
2 parents 94e4da3 + 4c243bc commit aac19a0
Show file tree
Hide file tree
Showing 41 changed files with 209 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
package edu.pitt.dbmi.ccd.web.ctrl;

import edu.pitt.dbmi.ccd.db.entity.UserAccount;
import edu.pitt.dbmi.ccd.db.service.SecurityQuestionService;
import edu.pitt.dbmi.ccd.db.service.UserAccountService;
import static edu.pitt.dbmi.ccd.web.ctrl.ViewPath.LOGIN_VIEW;
import static edu.pitt.dbmi.ccd.web.ctrl.ViewPath.REDIRECT_LOGIN;
import edu.pitt.dbmi.ccd.web.model.AppUser;
import edu.pitt.dbmi.ccd.web.model.user.UserRegistration;
import edu.pitt.dbmi.ccd.web.service.AppUserService;
import edu.pitt.dbmi.ccd.web.service.DataService;
import edu.pitt.dbmi.ccd.web.service.algo.AlgorithmResultService;
Expand Down Expand Up @@ -64,6 +66,8 @@ public class ApplicationController implements ViewPath {

private final ResultComparisonService resultComparisonService;

private final SecurityQuestionService securityQuestionService;

private final AppUserService appUserService;

@Autowired
Expand All @@ -72,11 +76,13 @@ public ApplicationController(
DataService dataService,
AlgorithmResultService algorithmResultService,
ResultComparisonService resultComparisonService,
SecurityQuestionService securityQuestionService,
AppUserService appUserService) {
this.userAccountService = userAccountService;
this.dataService = dataService;
this.algorithmResultService = algorithmResultService;
this.resultComparisonService = resultComparisonService;
this.securityQuestionService = securityQuestionService;
this.appUserService = appUserService;
}

Expand All @@ -98,7 +104,7 @@ public String showHomePage(
}

@RequestMapping(value = LOGIN, method = RequestMethod.GET)
public String showLoginPage(final SessionStatus sessionStatus) {
public String showLoginPage(final SessionStatus sessionStatus, final Model model) {
Subject currentUser = SecurityUtils.getSubject();
if (sessionStatus.isComplete()) {
currentUser.logout();
Expand All @@ -108,6 +114,9 @@ public String showLoginPage(final SessionStatus sessionStatus) {
sessionStatus.setComplete();
}

model.addAttribute("userRegistration", new UserRegistration());
model.addAttribute("securityQuestions", securityQuestionService.findAllSecurityQuestion());

return LOGIN_VIEW;
}

Expand All @@ -120,6 +129,8 @@ public String processLogin(final UsernamePasswordToken credentials, final Model
} catch (AuthenticationException exception) {
LOGGER.warn(String.format("Failed login attempt from user %s.", username));
model.addAttribute("errorMsg", "Invalid username and/or password.");
model.addAttribute("userRegistration", new UserRegistration());
model.addAttribute("securityQuestions", securityQuestionService.findAllSecurityQuestion());
return LOGIN_VIEW;
}

Expand All @@ -134,6 +145,8 @@ public String processLogin(final UsernamePasswordToken credentials, final Model
} else {
currentUser.logout();
model.addAttribute("errorMsg", "Your account has not been activated.");
model.addAttribute("userRegistration", new UserRegistration());
model.addAttribute("securityQuestions", securityQuestionService.findAllSecurityQuestion());

return LOGIN_VIEW;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package edu.pitt.dbmi.ccd.web.model.user;

import edu.pitt.dbmi.ccd.db.entity.SecurityQuestion;

/**
*
* Jun 20, 2015 12:20:50 PM
Expand All @@ -32,6 +34,10 @@ public class UserRegistration {

private String password;

private SecurityQuestion secureQues;

private String secureAns;

private boolean agree;

public UserRegistration() {
Expand Down Expand Up @@ -61,6 +67,22 @@ public void setPassword(String password) {
this.password = password;
}

public SecurityQuestion getSecureQues() {
return secureQues;
}

public void setSecureQues(SecurityQuestion secureQues) {
this.secureQues = secureQues;
}

public String getSecureAns() {
return secureAns;
}

public void setSecureAns(String secureAns) {
this.secureAns = secureAns;
}

public boolean isAgree() {
return agree;
}
Expand Down
51 changes: 39 additions & 12 deletions src/main/java/edu/pitt/dbmi/ccd/web/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
package edu.pitt.dbmi.ccd.web.service;

import edu.pitt.dbmi.ccd.db.entity.Person;
import edu.pitt.dbmi.ccd.db.entity.SecurityAnswer;
import edu.pitt.dbmi.ccd.db.entity.UserAccount;
import edu.pitt.dbmi.ccd.db.service.SecurityAnswerService;
import edu.pitt.dbmi.ccd.db.service.UserAccountService;
import edu.pitt.dbmi.ccd.web.model.user.UserRegistration;
import edu.pitt.dbmi.ccd.web.service.mail.MailService;
import java.net.URI;
import java.util.Base64;
import java.util.Collections;
import java.util.Date;
import java.util.UUID;
import javax.mail.MessagingException;
Expand All @@ -34,6 +37,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.util.UriComponentsBuilder;

/**
Expand All @@ -51,6 +55,8 @@ public class UserService {

private final UserAccountService userAccountService;

private final SecurityAnswerService securityAnswerService;

private final DefaultPasswordService passwordService;

private final MailService mailService;
Expand All @@ -59,10 +65,12 @@ public class UserService {
public UserService(
@Value("${ccd.server.url:}") String serverUrl,
UserAccountService userAccountService,
SecurityAnswerService securityAnswerService,
DefaultPasswordService passwordService,
MailService mailService) {
this.serverUrl = serverUrl;
this.userAccountService = userAccountService;
this.securityAnswerService = securityAnswerService;
this.passwordService = passwordService;
this.mailService = mailService;
}
Expand Down Expand Up @@ -103,23 +111,42 @@ public boolean registerNewUser(
userAccount.setPerson(person);
userAccount.setUsername(username);

userAccountService.saveUserAccount(userAccount);

Thread t = new Thread(() -> {
try {
mailService.sendRegistrationActivation(username, email, url);
} catch (MessagingException exception) {
LOGGER.warn(String.format("Unable to send registration email for user '%s'.", username), exception);
}
});
t.start();

success = true;
SecurityAnswer securityAnswer = new SecurityAnswer();
securityAnswer.setAnswer(userRegistration.getSecureAns());
securityAnswer.setSecurityQuestion(userRegistration.getSecureQues());
securityAnswer.setUserAccounts(Collections.singleton(userAccount));

success = persistUserRegistration(userAccount, securityAnswer);
if (success) {
Thread t = new Thread(() -> {
try {
mailService.sendRegistrationActivation(username, email, url);
} catch (MessagingException exception) {
LOGGER.warn(String.format("Unable to send registration email for user '%s'.", username), exception);
}
});
t.start();
}
} catch (Exception exception) {
LOGGER.warn(exception.getMessage());
}

return success;
}

@Transactional(noRollbackFor = Exception.class)
private boolean persistUserRegistration(UserAccount userAccount, SecurityAnswer securityAnswer) throws Exception {
boolean flag = false;

try {
userAccountService.saveUserAccount(userAccount);
securityAnswerService.saveSecurityAnswer(securityAnswer);
flag = true;
} catch (Exception exception) {
throw new Exception("Unable to create new user account.");
}

return flag;
}

}
Binary file added src/main/resources/static/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/main/resources/static/css/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,19 @@ textarea#agreement {
padding: 6px;
color: #333;
resize: none;
}

fieldset.security_qa_border {
border: 1px groove #ddd !important;
padding: 0 1.4em 1.4em 1.4em !important;
margin: 0 0 1.5em 0 !important;
}

legend.security_qa_border {
font-size: 1.2em !important;
font-weight: bold !important;
text-align: left !important;
width:auto;
padding:0 10px;
border-bottom:none;
}
2 changes: 1 addition & 1 deletion src/main/resources/static/css/login.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added src/main/resources/static/favicon.ico
Binary file not shown.
11 changes: 10 additions & 1 deletion src/main/resources/static/js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,22 @@ $(document).ready(function () {
},
confirmPassword: {
equalTo: "#password"
},
secureQues: {
required: true
},
secureAns: {
maxlength: 25,
required: true
}
},
messages: {
username: "Please enter a valid username (no white space).",
email: "Please enter a valid email.",
password: "Please enter valid a password (5-25 chars).",
confirmPassword: "Please reenter password."
confirmPassword: "Please reenter password.",
secureQues: "Please select a security question.",
secureAns: "Please enter the security answer."
},
highlight: function (element) {
$(element).closest('.form-group').addClass('has-error');
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/js/login.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<meta name="description" content="Center for Causal Discovery" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CCD: Algorithm Run Results</title>
<link rel="apple-touch-icon" href="../../static/apple-touch-icon.png" th:href="@{/apple-touch-icon.png}" />
<link rel="icon" href="../../static/favicon.ico" th:href="@{/favicon.ico}" />
<link rel="stylesheet" href="../../static/vendors/bootstrap/css/bootstrap.min.css" th:href="@{/vendors/bootstrap/css/bootstrap.min.css}" />
<link rel="stylesheet" href="../../static/vendors/bootstrap/css/bootstrap-theme.min.css" th:href="@{/vendors/bootstrap/css/bootstrap-theme.min.css}" />
<link rel="stylesheet" href="../../static/vendors/metisMenu/metisMenu.min.css" th:href="@{/vendors/metisMenu/metisMenu.min.css}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<meta name="description" content="Center for Causal Discovery" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CCD: Algorithm Compare Results</title>
<link rel="apple-touch-icon" href="../../static/apple-touch-icon.png" th:href="@{/apple-touch-icon.png}" />
<link rel="icon" href="../../static/favicon.ico" th:href="@{/favicon.ico}" />
<link rel="stylesheet" href="../../static/vendors/bootstrap/css/bootstrap.min.css" th:href="@{/vendors/bootstrap/css/bootstrap.min.css}" />
<link rel="stylesheet" href="../../static/vendors/bootstrap/css/bootstrap-theme.min.css" th:href="@{/vendors/bootstrap/css/bootstrap-theme.min.css}" />
<link rel="stylesheet" href="../../static/vendors/metisMenu/metisMenu.min.css" th:href="@{/vendors/metisMenu/metisMenu.min.css}" />
Expand All @@ -24,7 +26,7 @@
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h3 class="page-header">Results Comparison</h3>
<h3 class="page-header">Result Comparisons</h3>
</div>
</div>
<div class="row">
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/templates/algorithm/algorithmResults.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<meta name="description" content="Center for Causal Discovery" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CCD: Algorithm Run Results</title>
<link rel="apple-touch-icon" href="../../static/apple-touch-icon.png" th:href="@{/apple-touch-icon.png}" />
<link rel="icon" href="../../static/favicon.ico" th:href="@{/favicon.ico}" />
<link rel="stylesheet" href="../../static/vendors/bootstrap/css/bootstrap.min.css" th:href="@{/vendors/bootstrap/css/bootstrap.min.css}" />
<link rel="stylesheet" href="../../static/vendors/bootstrap/css/bootstrap-theme.min.css" th:href="@{/vendors/bootstrap/css/bootstrap-theme.min.css}" />
<link rel="stylesheet" href="../../static/vendors/metisMenu/metisMenu.min.css" th:href="@{/vendors/metisMenu/metisMenu.min.css}" />
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/templates/algorithm/d3graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<title>CCD: D3 Graph</title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="apple-touch-icon" href="../../static/apple-touch-icon.png" th:href="@{/apple-touch-icon.png}" />
<link rel="icon" href="../../static/favicon.ico" th:href="@{/favicon.ico}" />
<style>
.link {
fill: none;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/templates/algorithm/fgs.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<meta name="description" content="Center for Causal Discovery" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CCD: FGS</title>
<link rel="apple-touch-icon" href="../../static/apple-touch-icon.png" th:href="@{/apple-touch-icon.png}" />
<link rel="icon" href="../../static/favicon.ico" th:href="@{/favicon.ico}" />
<link rel="stylesheet" href="../../static/vendors/bootstrap/css/bootstrap.min.css" th:href="@{/vendors/bootstrap/css/bootstrap.min.css}" />
<link rel="stylesheet" href="../../static/vendors/bootstrap/css/bootstrap-theme.min.css" th:href="@{/vendors/bootstrap/css/bootstrap-theme.min.css}" />
<link rel="stylesheet" href="../../static/vendors/metisMenu/metisMenu.min.css" th:href="@{/vendors/metisMenu/metisMenu.min.css}" />
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/templates/algorithm/plot.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<meta name="description" content="Center for Causal Discovery" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CCD: Plot</title>
<link rel="apple-touch-icon" href="../../static/apple-touch-icon.png" th:href="@{/apple-touch-icon.png}" />
<link rel="icon" href="../../static/favicon.ico" th:href="@{/favicon.ico}" />
<link rel="stylesheet" href="../../static/vendors/bootstrap/css/bootstrap.min.css" th:href="@{/vendors/bootstrap/css/bootstrap.min.css}" />
<link rel="stylesheet" href="../../static/vendors/bootstrap/css/bootstrap-theme.min.css" th:href="@{/vendors/bootstrap/css/bootstrap-theme.min.css}" />
<link rel="stylesheet" href="../../static/vendors/metisMenu/metisMenu.min.css" th:href="@{/vendors/metisMenu/metisMenu.min.css}" />
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/templates/algorithm/resultError.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<meta name="description" content="Center for Causal Discovery" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CCD: Result Error</title>
<link rel="apple-touch-icon" href="../../static/apple-touch-icon.png" th:href="@{/apple-touch-icon.png}" />
<link rel="icon" href="../../static/favicon.ico" th:href="@{/favicon.ico}" />
</head>
<body>
<p th:each="error : ${errors}" th:text="${error}"></p>
Expand Down
Loading

0 comments on commit aac19a0

Please sign in to comment.