package com.uas.platform.b2b.controller;

import javax.servlet.http.HttpSession;

import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.uas.platform.b2b.model.User;
import com.uas.platform.b2b.support.SystemSession;

@RestController
@RequestMapping("/authentication")
public class AuthenticationController {
	
	@RequestMapping(method = RequestMethod.GET, headers = "Accept=application/json")
	@ResponseBody
	@ResponseStatus(value = HttpStatus.OK)
	public User getAuthentication(Authentication authentication, HttpSession session) {
		if (authentication == null) {
			return null;
		}
		return SystemSession.getUser();
	}
	
}
