modificamos el controladora para verificar si un usuario estaba registrado y confirmado
This commit is contained in:
@@ -3,6 +3,7 @@ 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.otros.ConfirmadoTF;
|
||||
import com.example.fercoganbackend.service.ContadorService;
|
||||
import com.example.fercoganbackend.service.UsuarioService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -33,9 +34,9 @@ public class AppController {
|
||||
|
||||
// Verificar si aprobado
|
||||
@GetMapping("/auth/verificar/{username}")
|
||||
public String verificar(@PathVariable String username) {
|
||||
boolean aprobado = usuarioService.estaAprobado(username);
|
||||
return aprobado ? "Usuario aprobado ✅" : "Usuario pendiente ❌";
|
||||
public ConfirmadoTF verificar(@PathVariable String username) {
|
||||
ConfirmadoTF aprobado = usuarioService.registradoYAprobado(username);
|
||||
return aprobado;
|
||||
}
|
||||
|
||||
// Listar pendientes (solo admin/super)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.example.fercoganbackend.otros;
|
||||
|
||||
public class ConfirmadoTF {
|
||||
private boolean authenticated;
|
||||
private boolean confirmed;
|
||||
|
||||
public ConfirmadoTF(){
|
||||
}
|
||||
|
||||
public boolean isAuthenticated() {
|
||||
return authenticated;
|
||||
}
|
||||
|
||||
public void setAuthenticated(boolean authenticated) {
|
||||
this.authenticated = authenticated;
|
||||
}
|
||||
|
||||
public boolean isConfirmed() {
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
public void setConfirmed(boolean confirmed) {
|
||||
this.confirmed = confirmed;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.example.fercoganbackend.service;
|
||||
import com.example.fercoganbackend.entity.Rol;
|
||||
import com.example.fercoganbackend.entity.Usuario;
|
||||
import com.example.fercoganbackend.otros.ConfirmadoTF;
|
||||
import com.example.fercoganbackend.repository.UsuarioRepository;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -39,4 +40,16 @@ public class UsuarioService {
|
||||
public boolean estaAprobado(String username) {
|
||||
return repo.findByUsername(username).map(Usuario::isAprobado).orElse(false);
|
||||
}
|
||||
public boolean estaRegistrado(String username) {
|
||||
return repo.findByUsername(username).isPresent();
|
||||
}
|
||||
|
||||
public ConfirmadoTF registradoYAprobado(String username){
|
||||
ConfirmadoTF confirmadotf = new ConfirmadoTF();
|
||||
confirmadotf.setAuthenticated(estaRegistrado(username));
|
||||
confirmadotf.setConfirmed(estaAprobado(username));
|
||||
return confirmadotf;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user