diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/service/RestartLessonService.java b/webgoat-container/src/main/java/org/owasp/webgoat/service/RestartLessonService.java index 4c17cbe0ac..73624dfda4 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/service/RestartLessonService.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/service/RestartLessonService.java @@ -33,6 +33,7 @@ import org.owasp.webgoat.users.UserTrackerRepository; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; @@ -58,4 +59,11 @@ public void restartLesson() { flywayLessons.clean(); flywayLessons.migrate(); } + + @PostMapping("/service/resetLessonDatabase.mvc") + @ResponseStatus(value = HttpStatus.OK) + public void resetLessonDatabase() { + flywayLessons.clean(); + flywayLessons.migrate(); + } } diff --git a/webgoat-container/src/main/resources/i18n/messages.properties b/webgoat-container/src/main/resources/i18n/messages.properties index d58990c3e8..9640d0bc85 100644 --- a/webgoat-container/src/main/resources/i18n/messages.properties +++ b/webgoat-container/src/main/resources/i18n/messages.properties @@ -54,6 +54,7 @@ sign.in=Sign in register.new=Register new user sign.up=Sign up register.title=Register +database.reset=Reset lesson database not.empty=This field is required. diff --git a/webgoat-container/src/main/resources/static/js/goatApp/view/GoatRouter.js b/webgoat-container/src/main/resources/static/js/goatApp/view/GoatRouter.js index 84a23334fb..0e684bb328 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/view/GoatRouter.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/view/GoatRouter.js @@ -43,7 +43,8 @@ define(['jquery', 'lesson/:name': 'lessonRoute', 'lesson/:name/:pageNum': 'lessonPageRoute', 'test/:param': 'testRoute', - 'reportCard': 'reportCard' + 'reportCard': 'reportCard', + 'resetLessonDatabase': 'resetLessonDatabase' }, lessonController: null, @@ -121,6 +122,13 @@ define(['jquery', render(new ReportCardView()); }); }, + + resetLessonDatabase: function() { + $.ajax({ + url:'service/resetLessonDatabase.mvc', + method:'POST' + }); + }, }); return GoatAppRouter; diff --git a/webgoat-container/src/main/resources/templates/main_new.html b/webgoat-container/src/main/resources/templates/main_new.html index edde993ab1..668d5718ba 100644 --- a/webgoat-container/src/main/resources/templates/main_new.html +++ b/webgoat-container/src/main/resources/templates/main_new.html @@ -84,20 +84,21 @@ +
+ + + +
- - - - - - -