mardi 13 octobre 2015

authentication using ember-simple-auth-devise and rails backend

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 http://ift.tt/1gQsesQ

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'
  }
...




Aucun commentaire:

Enregistrer un commentaire