allfree-springboot-backend / src / main / java / com / allfree / allfreespringbackend / auth / security / UserDetailsServiceImpl.java
UserDetailsServiceImpl.java
Raw
package com.allfree.allfreespringbackend.auth.security;

import com.allfree.allfreespringbackend.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class UserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    UserService userService;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return UserDetailsImpl.build(userService.getUserByUsername(username));
    }
}