简体   繁体   English

devise_token_auth forget password API 显示 Use POST /sign_in to sign in. GET is not supported 错误

[英]devise_token_auth forget password API shows Use POST /sign_in to sign in. GET is not supported error

Following this solution https://stackoverflow.com/a/47761138/7818637 I am designing forgot password flow APIs on rails where I am using devise_token_auth gem for authentication.遵循此解决方案https://stackoverflow.com/a/47761138/7818637我正在使用devise_token_auth gem 进行身份验证的轨道上设计忘记密码流 API。

1. A POST call to send a Password Reset Email 1. POST 调用发送密码重置 Email

URL: http://localhost:3000/client/auth/password URL: http://localhost:3000/client/auth/password

form-data: {email: 'john@gmail.com', redirect_url: 'http://localhost:3000/client/auth/sign_in'}表单数据: {email: 'john@gmail.com', redirect_url: 'http://localhost:3000/client/auth/sign_in'}

拨打电话以发送密码重置电子邮件

2. A GET call to verify the password reset token (clicked in email) 2. 验证密码重置令牌的 GET 调用(在电子邮件中单击)

I am receiving the the following URL on my console containing redirect_url and reset_password_token :我在控制台上收到以下 URL 包含redirect_urlreset_password_token

http://localhost:3000/client/auth/password/edit?config=default&redirect_url=http%3A%2F%2Flocalhost%3A3000%2Fclient%2Fauth%2Fsign_in&reset_password_token=ZBsx64Gk1VBraM3THZTn

When I call on this URL, I am receiving the following error:当我调用这个 URL 时,我收到以下错误:

Use POST /sign_in to sign in. GET is not supported.

调用以验证密码重置令牌

What I have already tried:我已经尝试过的:

Following the issuehere I have found that I am already using include DeviseTokenAuth::Concerns::SetUserByToken in my controller.这里的问题之后,我发现我已经在我的 controller 中使用了include DeviseTokenAuth::Concerns::SetUserByToken SetUserByToken。

Console Logs:控制台日志:

控制台日志

When the users clicks the url in your email you redirect them to /password/edit path.当用户单击 email 中的 url 时,您会将他们重定向到/password/edit路径。 In this action you verify the user.在此操作中,您验证用户。 If everything goes right the user will be redirected in redirect_url which is the sign_in path in your case.如果一切顺利,用户将被重定向到redirect_url ,这是您的情况下的登录路径。

You should change the redirect_url in your email and create an action and a view in which the user will be redirected.您应该更改 email 中的redirect_url并创建将重定向用户的操作和视图。 In this new view you will have the fields so the user can reset the password.在这个新视图中,您将拥有字段,以便用户可以重置密码。 Make sure that the new url will use 'GET'.确保新的 url 将使用“GET”。 On form submission redirect user to sign_in path so he/she can log in with their new password.在提交表单时将用户重定向到登录路径,以便他/她可以使用新密码登录。

Please read https://devise-token-auth.gitbook.io/devise-token-auth/usage/reset_password for more info.请阅读https://devise-token-auth.gitbook.io/devise-token-auth/usage/reset_password了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用POST / sign_in登录。不支持GET。 Omniauth Facebook的 - Use POST /sign_in to sign in. GET is not supported. Omniauth-facebook 如何在devise_token_auth gem中成功登录后返回自定义JSON? - How to return custom JSON after successful sign_in in devise_token_auth gem? Rails + 设计 sign_in 错误 - Rails + devise sign_in error Devise_token_auth 重置密码流程 401 错误 - Devise_token_auth Reset Password Flow 401 Error Rails Devise testhelpers:sign_in正在使用get而不是post - Rails Devise testhelpers: sign_in is working with get but not post 授权仅在api调用中使用错误-devise_token_auth - authorized uses only error in api call - devise_token_auth 将Devise与Ruby on Rails一起使用,如果用户使用无效的auth_token,如何将用户发送到sign_in路径? - Using Devise with Ruby on Rails, how can I send the user to sign_in path if they use an invalid auth_token? 为什么我无法使用devise_token_auth和curl注销? - Why am I unable to sign out using devise_token_auth and curl? 生产服务器上的Rails“ / api / auth / sign_in” 404错误 - Rails “/api/auth/sign_in” 404 error on production server 过滤器链因呈现或重定向的:validate_sign_up_params而停止-devise_token_auth - Filter chain halted as :validate_sign_up_params rendered or redirected - devise_token_auth
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM