package asa.controller;

import asa.bean.Login;
import asa.service.LoginService;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.MediaType;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;

@RestController
@RequestMapping("/login")
public class LoginController {

	@Autowired
	private LoginService loginService;
	
	@RequestMapping(method = RequestMethod.GET)
	public void test(){
		System.out.println("Inside LoginController");
	}
	
    @RequestMapping(value="/auth",method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody Map<String,String> authenticateUser(@RequestBody Login login){
        System.out.println(login.getUsername());
		Map<String,String> map=new HashMap<>();
		/* 
	    	if(loginService.authenticate(login.getUsername(),login.getPassword())){
			//return "{'result':'success'}";
			map.put("result","success");
		}
		else{
			//return "{'result':'failure'}";
			map.put("result","failure");
		}
		*/
	    	map.put("result",loginService.authenticate(login.getUsername(),login.getPassword()));
		return map;
    }
	
	

}

@@ -1022,16 +1022,26 @@
 %09%7D%0A%09%09*/%0A
+%09    try%7B%0A
 %09    %09ma
@@ -1124,16 +1124,181 @@
 rd()));%0A
+%09    %7D%0A%09    catch(Exception e)%7B%0A%09    %09System.out.println(%22Exception at LoginController.authenticateUser() %22+e);%0A%09%09map.put(%22result%22,%22password%22);%0A%09    %7D%0A%09    finally%7B%0A
 %09%09return
@@ -1303,16 +1303,23 @@
 rn map;%0A
+%09    %7D%0A
     %7D%0A%09%0A

Update LoginController.java