Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed 422 Unprocessable Entity [Rails 5 API only, React with J-Toker] #904

Closed
nthock opened this issue Jun 11, 2017 · 4 comments
Closed

Comments

@nthock
Copy link

nthock commented Jun 11, 2017

Sorry that I have to post this issue as I am stuck for a few days. I am using Rails 5 API-only app hosted with Heroku. I try to use React as the front end to do user authentication with J-Toker.

However, I keep getting the error "Completed 422 Unprocessable Entity". I have set the settings using Rack Cors gem to allow origin from any domains. So I really don't know what is wrong. Is there anyone who experience this can share how do you deal with this issue:

Here's my code:

application_controller.rb

class ApplicationController < ActionController::API
  include DeviseTokenAuth::Concerns::SetUserByToken
  respond_to :json

end

In my React:

Registration_form.js

Auth.configure({
  apiUrl: <Heroku URL>
});

handleSubmit = (e) => {
    e.preventDefault();
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
        this.setState({ email: values.email });
        this.setState({ password: values.password });
        this.setState({ password_confirmation: values.password_confirmation });

        Auth.emailSignUp({
          email: this.state.email,
          password: this.state.password,
          password_confirmation: this.state.password_confirmation
        });

      }
    });
  }

I do not think the issue lies with J-Toker. Really thank you so much for your help on this.

@pnewsam
Copy link
Contributor

pnewsam commented Sep 13, 2017

Was having the same issue myself, but I think I found the problem. In the DeviseTokenAuth Registrations Controller it is expecting a "confirm_success_url" param to be included along with the email, password, and password_confirmation. Try adding that and seeing how it goes.

@zachfeldman
Copy link
Contributor

Workaround posted, so closing this one for now.

@moyuanhuang
Copy link

In the request response, you can inspect the error message to see why your request got denied. Mine was

"errors":{"password":["is too short (minimum is 8 characters)"],"full_messages":["Password is too short (minimum is 8 characters)"]}

@treva556
Copy link

treva556 commented Oct 9, 2023

@moyuanhuang how did you solve it, i have same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants