ruby-on-rails - 设计令牌身份验证不使用 React 返回访问令牌
问题描述
我正在将应用程序从使用设计转移到设计令牌身份验证。我已经添加了 gem,设置了所有东西等。我的问题在于,当我从 React(使用 axios)向后端发出请求时,它会返回用户(应该如此),但不会返回访问权限-token 标头。所有,我得到的是:
缓存控制:“最大年龄=0,私有,必须重新验证”内容类型:“应用程序/json;字符集=utf-8”
我确实从后端获取了用户对象,所以我知道这是一个有效的登录。我还看到令牌被添加到数据库中:
更新用户 SET 令牌 = '
这是我通过 axios 打来的电话:
export const userLogin = (options) => ((dispatch) => {
return axios.post(`${process.env.DOMAIN}/auth/sign_in`, {email:
options.username, password: options.password})
.then((response) => {
console.log("response is: ", response);
dispatch(setUser(response))
dispatch(loginError('', false))
})
.catch((response) => {
dispatch(loginError('Username or Password is incorrect, please try again',
true))
})
})
我已经对此进行了大量研究,并尝试恢复到旧版本的 active_model_serializers ,但这并没有帮助。上面的 console.log 显示了很多信息: config data headers request status statusText
响应是 200 OK。
解决方案
推荐阅读
- javascript - 将查询续集到 javascript .map
- scala - 组成必需值和可选值的期货
- angular - Angular 模块联盟 BrowserModule
- arrays - 使用 mongo 查询 [版本 < 3.6 ] 更新多级嵌套数组
- python - 如何使用 XLXS 编写器绘制数据框,“值”和“类别”轴中有多个值
- postgresql - AWS Glue - 如何使用物化视图?
- python - 使用 BeautifulSoup 进行网页抓取:获得 ValueError
- javascript - Snowflake UDF 在使用“LIMIT”时表现不同
- javascript - Firebase Auth Google Captcha电话号码验证反应原生
- flutter - Flutter:如何根据屏幕大小缩放文本