package demo;

import java.util.List;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MfaController {

    @GetMapping("/")
    String home() {
        return "public";
    }

    @GetMapping("/api/profile")
    String profile(Authentication auth) {
        return "profile of " + auth.getName();
    }

    @GetMapping("/admin/panel")
    String admin(Authentication auth) {
        List<String> a = auth.getAuthorities().stream().map(GrantedAuthority::getAuthority).sorted().toList();
        return "admin panel for " + auth.getName() + " " + a;
    }
}
