Bugfix: drop token after use
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>org.example</groupId>
|
<groupId>org.example</groupId>
|
||||||
<artifactId>Widerhall</artifactId>
|
<artifactId>Widerhall</artifactId>
|
||||||
<version>1.0.3</version>
|
<version>1.0.4</version>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
@@ -137,6 +137,11 @@ public class User {
|
|||||||
Database.open().query(sql).compile().run();
|
Database.open().query(sql).compile().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void dropPasswordToken() throws SQLException {
|
||||||
|
Database.open().update(TABLE_NAME).set(RESET_TOKEN,null).where(EMAIL,email).compile().run();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Withdraw a specific permission from the user object.
|
* Withdraw a specific permission from the user object.
|
||||||
* Updated permission flag will be written to db.
|
* Updated permission flag will be written to db.
|
||||||
|
|||||||
@@ -372,15 +372,18 @@ public class Web extends TemplateServlet {
|
|||||||
case RESET_PASSWORD:
|
case RESET_PASSWORD:
|
||||||
if (!isGet) return resetPassword(req,resp);
|
if (!isGet) return resetPassword(req,resp);
|
||||||
// TODO: move following code into resetPassword method
|
// TODO: move following code into resetPassword method
|
||||||
|
var token = req.getParameter(TOKEN);
|
||||||
|
if (token != null){
|
||||||
try {
|
try {
|
||||||
user = User.byToken(req.getParameter(TOKEN));
|
user = User.byToken(req.getParameter(TOKEN));
|
||||||
if (user != null) {
|
if (user == null) return loadTemplate(path,Map.of(ERROR,"Failed to find user for token!"),resp);
|
||||||
|
user.dropPasswordToken();
|
||||||
req.getSession().setAttribute("user",user);
|
req.getSession().setAttribute("user",user);
|
||||||
return redirectTo(NEW_PASSWORD_FORM,resp);
|
return redirectTo(NEW_PASSWORD_FORM,resp);
|
||||||
}
|
|
||||||
} catch (SQLException sqle){
|
} catch (SQLException sqle){
|
||||||
return loadTemplate(path,Map.of(ERROR,"Failed to add user for token!"),resp);
|
return loadTemplate(path,Map.of(ERROR,"Failed to add user for token!"),resp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
var email = req.getParameter(EMAIL);
|
var email = req.getParameter(EMAIL);
|
||||||
return loadTemplate(path,email == null ? null : Map.of(EMAIL,email),resp);
|
return loadTemplate(path,email == null ? null : Map.of(EMAIL,email),resp);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="footer">
|
<div class="footer">
|
||||||
Widerhall Mail Distributor.
|
Widerhall Mail Distributor.
|
||||||
Version 1.0.3.
|
Version 1.0.4.
|
||||||
Get the sources at <a target="_blank" href="https://git.srsoftware.de/StephanRichter/Widerhall">git.srsoftware.de</a>
|
Get the sources at <a target="_blank" href="https://git.srsoftware.de/StephanRichter/Widerhall">git.srsoftware.de</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user