package sg.ncl.service.authentication.controllers;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import sg.ncl.service.authentication.AuthenticationService;

import javax.inject.Inject;

/**
 * @author Christopher Zhong
 */
@RestController
@RequestMapping(path = "/authentication", produces = MediaType.APPLICATION_JSON_VALUE)
public class AuthenticationController {

    private final AuthenticationService authenticationService;

    @Inject
    protected AuthenticationController(final AuthenticationService authenticationService) {
        this.authenticationService = authenticationService;
    }

    @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public String login(@RequestHeader("X-Username") String username, @RequestHeader("X-Password") String password) {
        return authenticationService.login(username, password);
    }

    @RequestMapping(method = RequestMethod.DELETE)
    public void logout() {
        authenticationService.logout();
    }

}

@@ -334,24 +334,77 @@
 Controller;%0A
+import sg.ncl.common.exceptions.BadRequestException;%0A
 import sg.nc
@@ -1105,24 +1105,135 @@
 password) %7B%0A
+        if (username.isEmpty() %7C%7C password.isEmpty()) %7B%0A            throw new BadRequestException();%0A        %7D%0A
         retu

Add error checking to username and password (DEV-99)