#271 Reset lesson does not work anymore
This commit is contained in:
parent
5babe19f2b
commit
2728158f14
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -187,22 +187,11 @@ define(['jquery',
|
||||
|
||||
this.restartLesson = function() {
|
||||
var self=this;
|
||||
var fragment = "attack/" + self.scr + "/" + self.menu;
|
||||
console.log("Navigating to " + fragment);
|
||||
// Avoiding the trigger event - handle - navigate loop by
|
||||
// loading the lesson explicitly (after executing the restart
|
||||
// servlet).
|
||||
goatRouter.navigate(fragment);
|
||||
// Resetting the user's lesson state (assuming a single browser
|
||||
// and session per user).
|
||||
$.ajax({
|
||||
url:'service/restartlesson.mvc',
|
||||
method:'GET'
|
||||
}).done(function(text) {
|
||||
console.log("Received a response from the restart servlet: '" + text + "'");
|
||||
// Explicitly loading the lesson instead of triggering an
|
||||
// event in goatRouter.navigate().
|
||||
self.loadLesson(self.scr,self.menu);
|
||||
}).done(function(lessonLink) {
|
||||
self.loadLesson(self.name);
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user