auth listo y contador terminados
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package com.example.fercoganbackend.controller;
|
||||
|
||||
import com.example.fercoganbackend.component.ContadorWebSocketHandler;
|
||||
import com.example.fercoganbackend.entity.Rol;
|
||||
import com.example.fercoganbackend.entity.Usuario;
|
||||
import com.example.fercoganbackend.service.ContadorService;
|
||||
import com.example.fercoganbackend.service.UsuarioService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class AppController {
|
||||
|
||||
private final UsuarioService usuarioService;
|
||||
private final ContadorService contadorService;
|
||||
private final ContadorWebSocketHandler webSocketHandler;
|
||||
|
||||
public AppController(UsuarioService usuarioService, ContadorService contadorService, ContadorWebSocketHandler webSocketHandler) {
|
||||
this.usuarioService = usuarioService;
|
||||
this.contadorService = contadorService;
|
||||
this.webSocketHandler = webSocketHandler;
|
||||
}
|
||||
|
||||
// Registro
|
||||
@PostMapping("/auth/registrar")
|
||||
public String registrar(@RequestParam String username,
|
||||
@RequestParam String password,
|
||||
@RequestParam Set<Rol> roles) {
|
||||
usuarioService.registrarUsuario(username, password, roles);
|
||||
return "Usuario registrado, pendiente de aprobación";
|
||||
}
|
||||
|
||||
// Verificar si aprobado
|
||||
@GetMapping("/auth/verificar/{username}")
|
||||
public String verificar(@PathVariable String username) {
|
||||
boolean aprobado = usuarioService.estaAprobado(username);
|
||||
return aprobado ? "Usuario aprobado ✅" : "Usuario pendiente ❌";
|
||||
}
|
||||
|
||||
// Listar pendientes (solo admin/super)
|
||||
@GetMapping("/admin/pendientes")
|
||||
public List<Usuario> pendientes() {
|
||||
return usuarioService.listarPendientes();
|
||||
}
|
||||
|
||||
// Aceptar usuario (solo admin/super)
|
||||
@PostMapping("/admin/aceptar/{id}")
|
||||
public String aceptar(@PathVariable Long id) {
|
||||
usuarioService.aceptarUsuario(id);
|
||||
return "Usuario aprobado ✅";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user