登录后如何修改密码? [英] How to change password after logging in?
本文介绍了登录后如何修改密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下代码更改密码,但收到请求失败,状态代码为 400".有人可以告诉我问题出在哪里吗?
I used the following code to change the password, but I get "Request failed with status code 400". Can someone give me an indication of where the problem is?
axios.post ('http: // localhost: 1337 / auth / reset-password', {
code: '',
password: '1234567',
passwordConfirmation: '1234567',
}
, {
headers: {
Authorization: `Bearer $ {this.currentUser.jwt}`
}
}
) .then (response => {
// Handle success.
console.log ('Your user \' s password has been changed. ');
})
.catch (error => {
// Handle error.
console.log ('An error occurred:', error);
});
}
提前致谢
推荐答案
您将不得不使用 PUT/users/:id
路由(来自用户 API)
You will have to use the PUT /users/:id
route (from the User API)
如果您希望用户使用此路由,则必须创建一个 isOwner 策略并将其应用于此路由.只让当前用户更新自己的密码,而不是所有用户的密码.
If you want this route used by a user, you will have to create a isOwner policy and apply it to this route. To let only the current user udpate it's own password and not all users password.
这里有一些文档:
这篇关于登录后如何修改密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文