package de.nilzbu.mytimetracker.security;

import com.vaadin.flow.spring.security.VaadinWebSecurity;
import de.nilzbu.mytimetracker.ui.view.LoginView;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

@Configuration
public class SecurityConfig extends VaadinWebSecurity {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        // Standard-Konfiguration von Vaadin-Security erweitern
        super.configure(http);

        // Login-View setzen
        setLoginView(http, LoginView.class);
    }

    @Bean
    public BCryptPasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}