QOL changes
- Authentication code only gets send now if you don't have one or your code expired - Added custom error page - Trying out scalable Interface
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.github.cato447.AbizeitungVotingSystem;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
|
||||
@SpringBootApplication
|
||||
|
||||
@@ -108,8 +108,13 @@ public class VotingController {
|
||||
LOGGER.warn(name + " has already submitted its candidates");
|
||||
return "errors/alreadysubmittedcandidates.html";
|
||||
} else {
|
||||
if (authCodesRepository.findByName(name) == null) {
|
||||
AuthCode authCode = tableAction.generateToken(name, RandomNumber.getRandomNumberString(), authCodesRepository);
|
||||
sendSimpleMessage(name, "Code zur Authentifizierung", "Dein Code lautet: " + authCode.getCode());
|
||||
} else if (authCodesRepository.findByName(name) != null && authCodesRepository.findByName(name).isExpired()){
|
||||
AuthCode authCode = tableAction.generateToken(name, RandomNumber.getRandomNumberString(), authCodesRepository);
|
||||
sendSimpleMessage(name, "Code zur Authentifizierung", "Dein Code lautet: " + authCode.getCode());
|
||||
}
|
||||
model.addAttribute("name", name);
|
||||
model.addAttribute("codeExpired", false);
|
||||
model.addAttribute("codeFalse", false);
|
||||
|
||||
@@ -37,6 +37,10 @@ public class AuthCode {
|
||||
return time;
|
||||
}
|
||||
|
||||
public boolean isExpired(){
|
||||
return System.currentTimeMillis() >= (time + 600*1000);
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ body {
|
||||
padding: 20px;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
transform: scale();
|
||||
}
|
||||
|
||||
h1 {
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
<body class="center-screen">
|
||||
|
||||
<script>
|
||||
var scale = Math.min(
|
||||
availableWidth / contentWidth,
|
||||
availableHeight / contentHeight
|
||||
);
|
||||
</script>
|
||||
|
||||
<h1 th:text="|Dir wurde ein Code an ${name} gesendet!|"></h1>
|
||||
<h2>Bitte gebe den Authentifizierungscode ein</h2>
|
||||
<form action="#" id="passForm" th:action="@{/vote}" method="post">
|
||||
|
||||
10
src/main/resources/templates/error.html
Normal file
10
src/main/resources/templates/error.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<body>
|
||||
<h1>Something went wrong! </h1>
|
||||
<h2>Our Engineers are on it</h2>
|
||||
<a href="/">Go Home</a>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user