package org.artgasmator.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

@Controller
@SessionAttributes("loggedInUserName")
public class StartController {
	
	@RequestMapping(value="/home")
	public String index(Model model) {
		
		model.addAttribute("loggedInUserName", loggedInUserName());
		return "home";
	}
	
	
	private String loggedInUserName() {
		return SecurityContextHolder.getContext().getAuthentication().getName();
	}
}
