26 Commits

Author SHA1 Message Date
BrittanyBi
1c69c8998c PAN-54 IT WORKS 2019-05-01 22:32:09 -06:00
BrittanyBi
8cc31b5c21 Merge branches 'PAN-54' and 'master' of https://github.com/atusa17/ptp into PAN-54
# Conflicts:
#	src/main/java/edu/msudenver/tsp/website/Application.java
2019-05-01 22:03:15 -06:00
BrittanyBi
08bda7099a PAN-54 Runs successfully but closes before the webpage can be loaded. 2019-05-01 21:58:46 -06:00
Brittany
766ba2753a Merge pull request #32 from atusa17/PAN-53
Pan 53
2019-05-01 21:55:55 -06:00
dantanxiaotian
96a9e584af Merge branch 'master' of https://github.com/atusa17/ptp into PAN-53 2019-05-01 14:56:40 -06:00
dantanxiaotian
7465568c97 Add loginpage controller, login jsp and logincontroller unit test. 2019-05-01 14:55:38 -06:00
dantanxiaotian
d34ba70307 Merge pull request #30 from atusa17/PAN-64
Pan 64
2019-04-29 23:11:24 -06:00
BrittanyBi
8f809ff422 PAN-54 Clean slate that runs 2019-04-29 12:46:33 -06:00
BrittanyBi
071d195d2a Merge remote-tracking branch 'origin/PAN-54' into PAN-54 2019-04-24 16:39:14 -06:00
BrittanyBi
e72760c528 PAN-54 Working version includes no beans and no connection to the database. 2019-04-24 16:38:29 -06:00
Brittany
09d76d93c1 Deleted PasswordMatchChecker
It's no longer necessary
2019-04-24 16:10:43 -06:00
Brittany
52cc67ebfb Deleted ConfirmPasswordValidator
It's no longer necessary
2019-04-24 16:10:12 -06:00
BrittanyBi
3ee3d1bb06 PAN-64 Errors 2019-04-22 12:42:28 -06:00
Brittany
27b28c1f36 Merge branch 'master' into PAN-54 2019-04-17 19:30:28 -06:00
BrittanyBi
6ab0470fca PAN-64 Fixed bug in tests that was failing the 1st Travis build. 2019-04-15 20:49:56 -06:00
BrittanyBi
41a78babd9 Merge branches 'PAN-64' and 'master' of https://github.com/atusa17/ptp into PAN-64 2019-04-14 21:10:49 -06:00
BrittanyBi
ecd6584422 PAN-64 Refactored ParserService. 2019-04-14 20:29:11 -06:00
BrittanyBi
5de86dc498 PAN-64 Completed and refactored unit tests for ParserService. 2019-04-14 20:28:11 -06:00
BrittanyBi
cf49f9e980 PAN-54 Test. 2019-04-10 20:17:20 -06:00
BrittanyBi
f86b36aa17 PAN-54 Added call to UserService to query DB. 2019-04-07 23:55:15 -06:00
BrittanyBi
1a2715ec04 Merge branches 'PAN-54' and 'master' of https://github.com/atusa17/ptp into PAN-54 2019-04-07 20:37:36 -06:00
BrittanyBi
1a12f29755 PAN-54 Left this out of previous commit somehow. 2019-04-07 20:36:53 -06:00
BrittanyBi
4cc184b6e7 PAN-54 Client-side mostly working. Still need email validator and to handle the errors thrown by UserCreationController. Next stage after that is to query the DB for existing usernames - once for the registering party and once for the referrer category. 2019-04-07 20:34:52 -06:00
BrittanyBi
6f70785387 PAN-54 2019-04-03 20:14:54 -06:00
BrittanyBi
2a4adcbd08 Merge branches 'PAN-54' and 'master' of https://github.com/atusa17/ptp into PAN-54 2019-03-31 14:17:08 -06:00
BrittanyBi
0fc825e11b PAN-54 Created user registration page. 2019-03-24 15:37:39 -06:00
10 changed files with 278 additions and 1 deletions
+1
View File
@@ -99,6 +99,7 @@ repositories {
}
dependencies {
compile project(':services')
compile group: 'org.jacoco', name: 'org.jacoco.core', version: '0.8.3'
compile 'org.codehaus.groovy:groovy-all:2.3.11'
compile 'org.apache.commons:commons-lang3:3.5'
@@ -2,11 +2,16 @@ package edu.msudenver.tsp.website;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan("edu.msudenver.tsp")
public class Application {
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}
@@ -0,0 +1,46 @@
package edu.msudenver.tsp.website.controller;
import edu.msudenver.tsp.services.UserService;
import edu.msudenver.tsp.services.dto.Account;
import edu.msudenver.tsp.website.forms.UserCreationForm;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Slf4j
@Controller
@AllArgsConstructor
@RequestMapping("/createuser")
public class UserCreationController {
@Autowired
private final UserService userService;
@GetMapping({"/",""})
public ModelAndView createUserPage() {
LOG.info("Received request to display the user creation page: returning model with name 'User'");
return new ModelAndView("User");
}
@PostMapping({"/",""})
public String registerUser(@Validated final UserCreationForm userCreationForm, final Model model) {
model.addAttribute("username", userCreationForm.getUsername());
model.addAttribute("password", userCreationForm.getPassword());
model.addAttribute("emailAddress", userCreationForm.getEmailAddress());
LOG.info("Saving user {}...", userCreationForm);
final Account newUser = new Account();
newUser.setUsername(userCreationForm.getUsername());
newUser.setPassword(userCreationForm.getPassword());
userService.createAccount(newUser);
return "successfulRegistration";
}
}
@@ -0,0 +1,5 @@
package edu.msudenver.tsp.website.controller;
public class ValidationExceptionHandler {
}
@@ -0,0 +1,30 @@
package edu.msudenver.tsp.website.forms;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Getter
@Setter
public class UserCreationForm {
@NotNull
@NotEmpty
private String username;
@NotNull
@NotEmpty
private String password;
@NotNull
@NotEmpty
private String confirmPassword;
@NotNull
@NotEmpty
private String emailAddress;
@NotNull
private boolean agreedToTerms;
}
+5 -1
View File
@@ -1,2 +1,6 @@
spring.mvc.view.prefix:/WEB-INF/jsp/
spring.mvc.view.suffix:.jsp
spring.mvc.view.suffix:.jsp
persistence.api.connection.timeout.milliseconds=5000
persistence.api.socket.timeout.milliseconds=10000
persistence.api.base.url=http://localhost:8090/
+147
View File
@@ -0,0 +1,147 @@
<%@ taglib prefix="th" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>User Creation</title>
<style type="text/css">
input {
padding: 0.25em 0.5em;
border: 0.125em solid hsl(30, 76%, 10%);
outline: none;
}
/* Show green borders when valid */
input[data-state="valid"] {
border-color: hsl(120, 76%, 50%);
}
/* Show red borders when filled, but invalid */
input[data-state="invalid"] {
border-color: hsl(0, 76%, 50%);
}
.error-messages {
display:none;
}
.error-messages[data-state="valid"] {
display:none;
}
.error-messages[data-state="invalid"] {
display:inline;
color: hsl(0, 76%, 50%);
}
</style>
<script type="text/javascript">
document.getElementById("submit").disabled = true;
function checkIDBeginsWith900(){
var userID = document.getElementById("userID");
var error = document.getElementById("errorUserID");
var IDValue = userID.value;
if(IDValue - 900000000 > 0) {
userID.dataset.state = 'valid';
error.dataset.state = 'valid';
} else {
userID.dataset.state = 'invalid';
error.dataset.state = 'invalid';
}
}
function checkValidUsername(){
var username = document.getElementById("username");
var error = document.getElementById("errorUsername");
var re = /^\w+$/;
if(re.test(username.value)){
username.dataset.state = 'valid';
error.dataset.state = 'valid';
} else {
username.dataset.state = 'invalid';
error.dataset.state = 'invalid';
}
}
function checkValidPassword(){
var password = document.getElementById("password");
var error = document.getElementById("errorPassword");
var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$/;
if(re.test(password.value)){
password.dataset.state = 'valid';
error.dataset.state = 'valid';
} else {
password.dataset.state = 'invalid';
error.dataset.state = 'invalid';
}
}
function checkPasswordsMatch(){
var confirmPassword = document.getElementById("confirmPassword");
var password = document.getElementById("password");
var error = document.getElementById("errorConfirmPassword");
if(password.value === confirmPassword.value){
confirmPassword.dataset.state = 'valid';
error.dataset.state = 'valid';
} else {
confirmPassword.dataset.state = 'invalid';
error.dataset.state = 'invalid';
}
}
function checkAgreedToTerms(){
var agreedToTerms = document.getElementById("agreedToTerms");
var error = document.getElementById("errorAgreedToTerms");
if(agreedToTerms.checked === true){
error.dataset.state = 'valid';
document.getElementById("submit").disabled = false;
return true;
} else {
error.dataset.state = 'invalid';
document.getElementById("submit").disabled = true;
return false;
}
}
</script>
</head>
<body>
New User Registration:
<form method="post" action="" enctype="utf8">
<label for="username">Username:
<input type="text" name="username" id="username" onchange="checkValidUsername()"/>
<div class="error-messages" id="errorUsername">Username must contain only letters, numbers, and underscores</div>
</label>
<br>
<label for="password">Password:
<input type="text" name="password" id="password" onchange="checkValidPassword()"/>
<div class="error-messages" id="errorPassword">Password must be at least 8 characters long, including numbers, uppercase and lowercase letters.</div>
</label>
<br>
<label for="confirmPassword">Confirm Password:
<input type="text" name="confirmPassword" id="confirmPassword" onchange="checkPasswordsMatch()"/>
<div class="error-messages" id="errorConfirmPassword">Passwords do not match</div>
</label>
<br>
<label for="emailAddress">Email Address:
<input type="text" name="emailAddress" id="emailAddress" />
<div class="error-messages" id="errorEmailAddress">Invalid email address</div>
</label>
<br>
<label for="agreedToTerms">I agree to the terms and conditions.
<input type="checkbox" name="agreedToTerms" id="agreedToTerms" onclick="checkAgreedToTerms()"/>
<div class="error-messages" id="errorAgreedToTerms">You must agree to the terms and conditions in order to register.</div>
</label>
<br>
<input type="submit" id="submit" value="Submit" disabled="disabled"/>
</form>
</body>
</html>
+2
View File
@@ -21,6 +21,8 @@
<h2>Hello! Welcome to Pandamonium™ Theorem Prover!!</h2>
Click on this <strong><a href="/theorem/">link</a></strong> to visit theorem entering page.
<h4 class="text-center"><a href="/login">Sign In</a></h4>
<h4 class="text-center"><a href="/createuser">New here? Register</a></h4>
</div>
</div>
</body>
@@ -0,0 +1,11 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>You're Registered!</title>
</head>
<body>
Thank you for joining!
<br><b>Username: </b><%= request.getParameter("username")%>
<br><b>Email Address: </b><%= request.getParameter("emailAddress")%>
</body>
</html>
@@ -0,0 +1,26 @@
package edu.msudenver.tsp.website.controller;
import edu.msudenver.tsp.services.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.web.servlet.ModelAndView;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
@RunWith(MockitoJUnitRunner.class)
public class UserCreationControllerTest {
private final UserService userService = mock(UserService.class);
private final UserCreationController userCreationController = new UserCreationController(userService);
@Test
public void testCreateUserPage() {
final ModelAndView modelAndView = userCreationController.createUserPage();
assertNotNull(modelAndView);
assertEquals("User", modelAndView.getViewName());
}
}