#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.
|
* 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})
|
@RequestMapping(path = "/attack", method = {RequestMethod.GET, RequestMethod.POST})
|
||||||
public ModelAndView attack() {
|
public ModelAndView attack() {
|
||||||
return new ModelAndView("redirect:" + "start.mvc" + course.getFirstLesson().getLink());
|
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.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public String getLink() {
|
public String getLink() {
|
||||||
StringBuffer link = new StringBuffer(getPath());
|
return String.format("%s%s.lesson", getPath(), getId());
|
||||||
return link.append(getId()).toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,7 +218,5 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
|
|||||||
return getTitle();
|
return getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public abstract String getId();
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,14 @@
|
|||||||
package org.owasp.webgoat.service;
|
package org.owasp.webgoat.service;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.owasp.webgoat.lessons.AbstractLesson;
|
import org.owasp.webgoat.lessons.AbstractLesson;
|
||||||
import org.owasp.webgoat.session.UserTracker;
|
import org.owasp.webgoat.session.UserTracker;
|
||||||
import org.owasp.webgoat.session.WebSession;
|
import org.owasp.webgoat.session.WebSession;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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>
|
* <p>RestartLessonService class.</p>
|
||||||
@ -39,6 +41,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class RestartLessonService {
|
public class RestartLessonService {
|
||||||
|
|
||||||
private final WebSession webSession;
|
private final WebSession webSession;
|
||||||
@ -50,13 +53,11 @@ public class RestartLessonService {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
@RequestMapping(path = "/service/restartlesson.mvc", produces = "text/text")
|
@RequestMapping(path = "/service/restartlesson.mvc", produces = "text/text")
|
||||||
public
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
public void restartLesson() {
|
||||||
String restartLesson() {
|
|
||||||
AbstractLesson al = webSession.getCurrentLesson();
|
AbstractLesson al = webSession.getCurrentLesson();
|
||||||
System.out.println("Restarting lesson: " + al);
|
log.debug("Restarting lesson: " + al);
|
||||||
userTracker.getLessonTracker(al).reset();
|
|
||||||
|
|
||||||
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!
|
* Reset the tracker. We do not reset the number of attempts here!
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
void reset() {
|
||||||
solvedAssignments.clear();
|
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() {
|
this.restartLesson = function() {
|
||||||
var self=this;
|
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({
|
$.ajax({
|
||||||
url:'service/restartlesson.mvc',
|
url:'service/restartlesson.mvc',
|
||||||
method:'GET'
|
method:'GET'
|
||||||
}).done(function(text) {
|
}).done(function(lessonLink) {
|
||||||
console.log("Received a response from the restart servlet: '" + text + "'");
|
self.loadLesson(self.name);
|
||||||
// Explicitly loading the lesson instead of triggering an
|
|
||||||
// event in goatRouter.navigate().
|
|
||||||
self.loadLesson(self.scr,self.menu);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user