@@ -0,0 +1,1432 @@
+package nl.fhict.happynews.api;%0A%0Aimport nl.fhict.happynews.api.auth.User;%0Aimport nl.fhict.happynews.api.auth.UserRepository;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.context.event.ContextRefreshedEvent;%0Aimport org.springframework.context.event.EventListener;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport java.util.Collections;%0A%0A@Component%0Apublic class Setup %7B%0A%0A    private static final Logger logger = LoggerFactory.getLogger(Setup.class);%0A%0A    private final UserRepository userRepository;%0A%0A    @Autowired%0A    public Setup(UserRepository userRepository) %7B%0A        this.userRepository = userRepository;%0A    %7D%0A%0A    /**%0A     * Run setup when application starts.%0A     */%0A    @EventListener(ContextRefreshedEvent.class)%0A    public void contextRefreshedEvent() %7B%0A        logger.info(%22Running setup%22);%0A%0A        if (userRepository.count() == 0) %7B%0A            logger.info(%22No users have been configured, creating default user%22);%0A            User user = new User(%22admin%22, %22password%22, Collections.singleton(%22ROLE_%22 + WebSecurityConfig.Roles.ADMIN));%0A            userRepository.save(user);%0A            logger.info(%22Created user %5C%22%7B%7D%5C%22 with password %5C%22%7B%7D%5C%22. Change this password for security reasons!%22,%0A                user.getUsername(),%0A                %22password%22);%0A        %7D%0A%0A        logger.info(%22Setup completed%22);%0A    %7D%0A%7D%0A

Create default user on startup