package com.cristobalbernal.foro.seguridad.models;

import com.cristobalbernal.foro.Entidades.UsersEntity;
import com.cristobalbernal.foro.Respositorios.IUsers;
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;

public class UserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    private IUsers iUsers;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        UsersEntity users = iUsers.findByEmail(username);
        return new UserDetailsImpl(users);
    }

}
