package com.ffii.lioner.config.security.jwt.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.ffii.lioner.modules.user.entity.User;
import com.ffii.lioner.modules.user.entity.UserRepository;
import com.ffii.lioner.modules.user.service.UserAuthorityService;
import com.ffii.lioner.modules.user.service.UserService;

@Service
public class JwtUserDetailsService implements UserDetailsService {

	@Autowired
	UserRepository userRepository;

	@Autowired
	UserAuthorityService userAuthService;

	@Autowired
	UserService userService;


	@Override
	public User loadUserByUsername(String username) throws UsernameNotFoundException {
		return userService.loadUserOptByUsername(username).orElseThrow(() -> new UsernameNotFoundException(username));
	}

}
