@@ -0,0 +1,1496 @@
+package com.pollistics.services;%0A%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.security.core.userdetails.UserDetails;%0Aimport org.springframework.security.core.userdetails.UserDetailsService;%0Aimport org.springframework.security.core.userdetails.UsernameNotFoundException;%0Aimport org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;%0Aimport org.springframework.stereotype.Service;%0A%0Aimport com.pollistics.models.SecUserDetails;%0Aimport com.pollistics.models.User;%0Aimport com.pollistics.repositories.UserRepository;%0A%0A@Service%0Apublic class UserService implements UserDetailsService%7B%0A%0A    @Autowired%0A    private UserRepository userRepository;%0A    %0A    private BCryptPasswordEncoder passwordEncoder;%0A    %0A    public boolean userExists(String username) %7B%0A    %09return userRepository.findByUsername(username) != null;%0A    %7D%0A    %0A    public void createUser(User user) %7B%0A    %09passwordEncoder = new BCryptPasswordEncoder();%0A    %09String hashedPassword = passwordEncoder.encode(user.getPassword());%0A    %09user.setPassword(hashedPassword);%0A    %09userRepository.insert(user);%0A    %7D%0A%0A    @Override%0A    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException %7B%0A        User user = userRepository.findByUsername(username);%0A        if(user == null)%7B%0A            throw new UsernameNotFoundException(username);%0A        %7D else%7B%0A            UserDetails details = new SecUserDetails(user);%0A            return details;%0A        %7D%0A    %7D%0A%7D%0A

add UserService