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;
|
package com.github.cato447.AbizeitungVotingSystem;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
|||||||
@@ -108,8 +108,13 @@ public class VotingController {
|
|||||||
LOGGER.warn(name + " has already submitted its candidates");
|
LOGGER.warn(name + " has already submitted its candidates");
|
||||||
return "errors/alreadysubmittedcandidates.html";
|
return "errors/alreadysubmittedcandidates.html";
|
||||||
} else {
|
} else {
|
||||||
AuthCode authCode = tableAction.generateToken(name, RandomNumber.getRandomNumberString(), authCodesRepository);
|
if (authCodesRepository.findByName(name) == null) {
|
||||||
sendSimpleMessage(name, "Code zur Authentifizierung", "Dein Code lautet: " + authCode.getCode());
|
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("name", name);
|
||||||
model.addAttribute("codeExpired", false);
|
model.addAttribute("codeExpired", false);
|
||||||
model.addAttribute("codeFalse", false);
|
model.addAttribute("codeFalse", false);
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ public class AuthCode {
|
|||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isExpired(){
|
||||||
|
return System.currentTimeMillis() >= (time + 600*1000);
|
||||||
|
}
|
||||||
|
|
||||||
public void setTime(long time) {
|
public void setTime(long time) {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ body {
|
|||||||
padding: 20px;
|
padding: 20px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
transform: scale();
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
|
|||||||
@@ -10,6 +10,13 @@
|
|||||||
|
|
||||||
<body class="center-screen">
|
<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>
|
<h1 th:text="|Dir wurde ein Code an ${name} gesendet!|"></h1>
|
||||||
<h2>Bitte gebe den Authentifizierungscode ein</h2>
|
<h2>Bitte gebe den Authentifizierungscode ein</h2>
|
||||||
<form action="#" id="passForm" th:action="@{/vote}" method="post">
|
<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