I use Rails-api to create a test authentication application that uses the Devise_token_auth gem. User.rb model looks like
class User < ActiveRecord::Base
before_save :set_auth_token
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :omniauthable
include DeviseTokenAuth::Concerns::User
private
def set_auth_token
if self.authentication_token.blank?
self.authentication_token = generate_authentication_token
end
end
def generate_authentication_token
loop do
token = Devise.friendly_token
break token unless User.where(authentication_token: token).first
end
end
end
routes.rb contains
mount_devise_token_auth_for 'User', at: 'auth'
I also use the default SessionController and RegistrationsController defined using the DeviseTokenAuth gem
My interface is created in Ember-cli, where I created a login form that uses Ember-simple-auth-devise, Defise authorizer to call / sign _in url rails api. A simple Ember algorithm wraps parameters such as
{"user"=>{"password"=>"[FILTERED]", "email"=>"test@mail.com"}}
while DeviseTokenAuth rails expect query parameters such as
{"password"=>"[FILTERED]", "email"=>"test@mail.com"}
An error has occurred
Processing by DeviseTokenAuth::RegistrationsController
Parameters: {"user"=>{"password"=>"[FILTERED]", "email"=>"test@mail.com"}}
Unpermitted parameter: user
, Rails DeviseTokenAuth gem , "". OR Ember-simple-auth , , , , .
Ember-simple-auth null,
ENV['simple-auth-devise'] = {
resourceName: null,
serverTokenEndpoint: 'http://localhost:3000/auth/sign_in'
};
Ember-simple-auth-devise?
, "" , DeviseTokenAuth gem?
:
devise_token_auth (0.1.36)
devise (~> 3.5.2)
rails (~> 4.2)
"ember-simple-auth": "0.8.0"