【发布时间】:2021-10-17 05:20:13
【问题描述】:
如何对已经完成的数据进行数据认证。使用 jwt 比较该数据以验证信息。 我有一个带有 springboot 安全库的 spring 应用程序,我正在使用 angular 在 JWT 中进行验证,我需要读取 mysql 数据库中的纯文本文件,我该如何验证信息。 当用户登录时,它会使用数据库中的信息进行验证。
login(): void {
console.log(this.usuario);
if (this.usuario.username == null || this.usuario.password == null) {
swal('Error Login', 'Username o password vacías!', 'error');
return;
}
this.authService.login(this.usuario).subscribe(response => {
console.log(response);
this.authService.guardarUsuario(response.access_token);
this.authService.guardarToken(response.access_token);
let usuario = this.authService.usuario;
this.router.navigate(['/clientes']);
swal('Login', `Hola ${usuario.username}, has iniciado sesión con éxito!`, 'success');
}, err => {
if (err.status == 400) {
swal('Error Login', 'Usuario o clave incorrectas!', 'error');
}
}
);
}
【问题讨论】:
-
阅读您的问题并不清楚您要解决的问题。您的代码与
login操作相关,但您提到Using jwt to compare that data to validate information,您要做什么?在@JuanBerzosaTejero 的回答中,他认为您的问题与如何在每个“登录后”请求中发送JWT token有关。所以,问题还是一样,你要解决的具体用例是什么? -
我同意@dotore
标签: angular spring spring-security jwt