0

I am trying to implement a authentication system in ember with the following versions:

DEBUG: -------------------------------
ember.debug.js:5378 DEBUG: Ember                    : 1.13.7
ember.debug.js:5378 DEBUG: Ember Data               : 1.13.8
ember.debug.js:5378 DEBUG: jQuery                   : 1.11.3
ember.debug.js:5378 DEBUG: Ember Simple Auth        : 0.8.0
ember.debug.js:5378 DEBUG: Ember Simple Auth Devise : 0.8.0
ember.debug.js:5378 DEBUG: -------------------------------

I followed the instructions on github for https://github.com/simplabs/ember-simple-auth/tree/master/packages/ember-simple-auth-devise

Now when I hit 'sign up' it is returning a 500 error:

POST http://localhost:4200/users/sign_in 500 (Internal Server Error)

I feel like it should be going to localhost:3000/users/sign_in, but it isn't.

I launched the server with ember s --proxy http://localhost:3000 command, but don't understand whats happening.

Here is my code for reference:

controller/login.js

import Ember from 'ember';
import LoginControllerMixin from 'simple-auth/mixins/login-controller-mixin';

export default Ember.Controller.extend(LoginControllerMixin, {
  authenticator: 'simple-auth-authenticator:devise'
});

routes/login.js

import Ember from 'ember';
import UnauthenticatedRouteMixin from 'simple-auth/mixins/unauthenticated-route-mixin';

export default Ember.Route.extend(UnauthenticatedRouteMixin);

templates/application.hbs

<h2 id="title">Welcome to Ember.js - With Authentication!</h2>

{{#if session.isAuthenticated}}
    Hi, {{session.email}}
    <br/>
    You can't see this text unless you're logged in!
    <br/>
    Click this button to logout:
    <button {{action 'invalidateSession'}}>Logout</button>
    <br/>
    If you try to go to the
    {{#link-to "login"}}Login{{/link-to}}
    page, you should get redirected!
{{else}}
  {{#link-to "login"}}Login{{/link-to}}
{{/if}}

{{outlet}}

templates/login.hbs

<form {{action "authenticate" on="submit"}}>
    <div>
        <label for="identification">E-mail</label><br />
      {{input value=identification placeholder="E-mail" type="text" name="email"}}
    </div>

    <div>
        <label for="password">Password</label><br />
      {{input value=password placeholder="Password" type="password" name="password"}}
    </div>

    <div>
        <button type="submit">Log in</button>
    </div>
</form>

config/environment.js

...
  ENV['simple-auth'] = {
    authorizer: 'simple-auth-authorizer:devise'
  }

  ENV['simple-auth-devise'] = {
    tokenAttributeName: 'token',
    identificationAttributeName: 'email'
  }
...

My rails routes looks like:

  devise_for :users, controllers: { sessions: 'sessions' }
3
  • does the request ever reach the Rails backend? Commented Oct 13, 2015 at 17:59
  • yes, it returns, ActionController::RoutingError (No route matches [POST] "/users/sign_in"): (added my devise routes in above) Commented Oct 13, 2015 at 18:45
  • That means the /users/sign_in route isn't configured in the Rails app, this the 500 error Commented Oct 13, 2015 at 19:51

1 Answer 1

1

In your routes.rb file you might need adding at: 'users' as the default route provided by devise for sign_in is http://ip_address_to_your_server/sign_in and to create your custom url like http://localhost:3000/users/sign_in you have to map it on 'users'. The resulting code would look like

devise_for :users, at 'users',controllers: { sessions: 'sessions' }

This way you will be able to call the SessionsController at /users

Hope this helps. Otherwise please consider posting the code implemented at your rails backend because the problem is at Rails end.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.