使用Cookie的Angular 6身份验证 [英] Angular 6 auth using cookies

查看:134
本文介绍了使用Cookie的Angular 6身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于如何在Angular 6中实现Cookie身份验证的任何想法?
我曾尝试使用AuthGuard,但由于Cookie为HttpOnly,因此无法检查用户是否已通过身份验证,因此我无法访问其内容。
我需要它来保护某些路线。

Any idea on how to implement cookie auth in Angular 6? I have tried using AuthGuard but I'm not able to check if the user is authenticated or not because the cookie is HttpOnly so I can't access its content. I need this to protect some routes.

谢谢!

推荐答案

使用JWT,您应该保存令牌,必须保留cookie中的密钥。

with JWT you should save the token, you must kepp the key in the cookie.

这篇关于使用Cookie的Angular 6身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆