Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sankalp7654 committed Jan 20, 2020
1 parent 482a99e commit c111d4d
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public void InitBinder(WebDataBinder binder) {

@RequestMapping(value = "/list-todos", method = RequestMethod.GET)
public String showTodos(ModelMap model) {
String name = getLoggedInUserName(model);
String name = getLoggedInUserName();
model.put("name", name);
model.put("list", service.retrieveTodos("in28Minutes"));
model.put("list", service.retrieveTodos(getLoggedInUserName()));
return "list-todos";
}

private String getLoggedInUserName(ModelMap model) {
private String getLoggedInUserName() {
Object principal = SecurityContextHolder.getContext()
.getAuthentication().getPrincipal();

Expand All @@ -62,7 +62,7 @@ private String getLoggedInUserName(ModelMap model) {

@RequestMapping(value = "/add-todo", method = RequestMethod.GET)
public String showAddTodoPage(ModelMap model) {
model.addAttribute("todo", new Todo(0, getLoggedInUserName(model), "Default Desc",
model.addAttribute("todo", new Todo(0, getLoggedInUserName(), "Default Desc",
new Date(), false));
return "todo";
}
Expand All @@ -73,7 +73,7 @@ public String addATodo(ModelMap model, @Valid Todo todo, BindingResult result) {
return "todo";
}

service.addTodo(getLoggedInUserName(model), todo.getDesc(), todo.getTargetDate(), false);
service.addTodo(getLoggedInUserName(), todo.getDesc(), todo.getTargetDate(), false);
model.put("list", service.retrieveTodos("in28Minutes"));
return "redirect:/list-todos";
}
Expand All @@ -87,7 +87,7 @@ public String updateTodo(@RequestParam int id, ModelMap model) {

@RequestMapping(value="/update-todo", method=RequestMethod.POST)
public String showUpdateTodoPage(@Valid Todo todo, BindingResult result, ModelMap model) {
todo.setUser(getLoggedInUserName(model));
todo.setUser(getLoggedInUserName());
if(result.hasErrors()) {
return "todo";
}
Expand Down

0 comments on commit c111d4d

Please sign in to comment.