#271 Reset lesson does not work anymore
This commit is contained in:
@ -52,7 +52,6 @@ public class HammerHead {
|
||||
/**
|
||||
* Entry point for WebGoat, redirects to the first lesson found within the course.
|
||||
*/
|
||||
//// TODO: 11/6/2016 course necessary?
|
||||
@RequestMapping(path = "/attack", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public ModelAndView attack() {
|
||||
return new ModelAndView("redirect:" + "start.mvc" + course.getFirstLesson().getLink());
|
||||
|
@ -206,8 +206,7 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getLink() {
|
||||
StringBuffer link = new StringBuffer(getPath());
|
||||
return link.append(getId()).toString();
|
||||
return String.format("%s%s.lesson", getPath(), getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,7 +218,5 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
|
||||
return getTitle();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return "";
|
||||
}
|
||||
public abstract String getId();
|
||||
}
|
||||
|
@ -24,12 +24,14 @@
|
||||
package org.owasp.webgoat.service;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.owasp.webgoat.lessons.AbstractLesson;
|
||||
import org.owasp.webgoat.session.UserTracker;
|
||||
import org.owasp.webgoat.session.WebSession;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
/**
|
||||
* <p>RestartLessonService class.</p>
|
||||
@ -39,6 +41,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
*/
|
||||
@Controller
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
public class RestartLessonService {
|
||||
|
||||
private final WebSession webSession;
|
||||
@ -50,13 +53,11 @@ public class RestartLessonService {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
@RequestMapping(path = "/service/restartlesson.mvc", produces = "text/text")
|
||||
public
|
||||
@ResponseBody
|
||||
String restartLesson() {
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public void restartLesson() {
|
||||
AbstractLesson al = webSession.getCurrentLesson();
|
||||
System.out.println("Restarting lesson: " + al);
|
||||
userTracker.getLessonTracker(al).reset();
|
||||
log.debug("Restarting lesson: " + al);
|
||||
|
||||
return webSession.getCurrentLesson().getLink();
|
||||
userTracker.reset(al);
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class LessonTracker implements Serializable {
|
||||
/**
|
||||
* Reset the tracker. We do not reset the number of attempts here!
|
||||
*/
|
||||
public void reset() {
|
||||
void reset() {
|
||||
solvedAssignments.clear();
|
||||
}
|
||||
}
|
||||
|
@ -97,4 +97,8 @@ public class UserTracker {
|
||||
}
|
||||
|
||||
|
||||
public void reset(AbstractLesson al) {
|
||||
getLessonTracker(al).reset();
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user