package com.lynx.web.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

import com.lynx.domain.CurrentUser;

@ControllerAdvice
public class BaseControllerAdvice {

	@Value("${info.app.version}")
	private String applicationVersion;

	@ModelAttribute("currentUser")
	public CurrentUser getCurrentUser(Authentication authentication) {
		return (authentication == null) ? null : (CurrentUser) authentication.getPrincipal();
	}

	@ModelAttribute("applicationVersion")
	public String getApplicationVersion() {
		return applicationVersion;
	}

}
