Closed kevinansfield closed 11 years ago
Looking into it.
Please :-
ember-auth
is the only gem that has upgraded.The only other gem that was upgraded was barber from 0.4.1 -> 0.4.2. This is my current Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'sqlite3'
gem 'devise'
gem 'bcrypt-ruby'
gem 'inherited_resources'
gem 'active_model_serializers', github: 'rails-api/active_model_serializers'
gem 'bourbon'
gem 'haml-rails'
gem 'simple_form'
gem 'ember-source', '~> 1.0.0.rc2'
# javascript related
gem 'ember-rails', github: 'emberjs/ember-rails'
gem 'ember-auth-rails', github: 'heartsentwined/ember-auth-rails'
gem 'momentjs-rails'
group :assets do
gem 'jquery-rails'
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'bootstrap-sass'
end
group :development do
gem 'letter_opener'
gem 'annotate'
gem 'pry'
gem 'awesome_print'
gem 'pry-rails'
gem 'better_errors'
gem 'binding_of_caller'
end
group :test, :development do
gem 'rspec-rails' # for tests
gem 'spork' # speedier tests
gem 'guard-rspec' # watch app files
gem 'guard-spork' # spork integration
gem 'database_cleaner' # cleanup database in tests
gem 'fabrication' # model stubber
gem 'shoulda' # model spec tester
gem 'rb-inotify', require: false # Linux file notification
gem 'rb-fsevent', require: false # OSX file notification
gem 'rb-fchange', require: false # Windows file notification
end
Client sign in controller:
App.SignInController = Ember.ObjectController.extend Auth.SignInController,
login: null
password: null
remember: true
signIn: ->
@registerRedirect()
Auth.signIn
login: @get 'login'
password: @get 'password'
remember: @get 'remember'
Server-side session controller:
class SessionsController < Devise::SessionsController
respond_to :html, :json
def create
respond_to do |format|
format.html { super }
format.json do
unless (params[:login].present? && params[:password].present?) || (params[:remember_token].present?)
return missing_params
end
build_resource
resource = if params[:remember_token]
resource_from_remember_token
else
resource_from_credentials
end
return invalid_credentials unless resource
resource.ensure_authentication_token!
data = {
user_id: resource.id,
auth_token: resource.authentication_token,
}
if params[:remember]
resource.remember_me!
data[:remember_token] = remember_token(resource)
end
render json: data, status: 201
end
end
end
def destroy
respond_to do |format|
format.html { super }
format.json do
return missing_params unless params[:auth_token]
resource = resource_class.find_by_authentication_token(params[:auth_token])
return invalid_credentials unless resource
resource.reset_authentication_token!
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
render json: {user_id: resource.id}, status: 200
end
end
end
protected
def resource_from_credentials
data = { login: params[:login] }
if res = resource_class.find_for_database_authentication(data)
if res.valid_password?(params[:password])
res
end
end
end
def resource_from_remember_token
token = params[:remember_token]
id, identifier = token.split('-')
resource_class.serialize_from_cookie(id, identifier)
end
def remember_token(resource)
data = resource_class.serialize_into_cookie(resource)
"#{data.first.first}-#{data.last}"
end
def missing_params
warden.custom_failure!
render json: {}, status: 400
end
def invalid_credentials
warden.custom_failure!
render json: {}, status: 401
end
end
Ah, I'm guessing the Gemfile.lock will be useful for version information:
GIT
remote: git://github.com/emberjs/ember-rails.git
revision: 4dc902b4e1c5a1a6dadc97cc12524df3d7591fac
specs:
ember-rails (0.11.1)
active_model_serializers
barber (>= 0.4.1)
ember-data-source
ember-source
execjs (>= 1.2)
railties (>= 3.1)
GIT
remote: git://github.com/heartsentwined/ember-auth-rails.git
revision: 4312205147094ef3cbd0098594eba913c1d12f59
specs:
ember-auth-rails (4.0.1)
ember-auth-source
rails
GIT
remote: git://github.com/rails-api/active_model_serializers.git
revision: ab5d40f38b2b7c8c9155292938f21f3af0fa8027
specs:
active_model_serializers (0.7.0)
activemodel (>= 3.0)
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.13)
actionpack (= 3.2.13)
mail (~> 2.5.3)
actionpack (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
activerecord (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
addressable (2.3.3)
annotate (2.5.0)
rake
arel (3.0.2)
awesome_print (1.1.0)
barber (0.4.2)
ember-source
execjs
handlebars-source
bcrypt-ruby (3.0.1)
better_errors (0.7.2)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.1)
debug_inspector (>= 0.0.1)
bootstrap-sass (2.3.1.0)
sass (~> 3.2)
bourbon (3.1.1)
sass (>= 3.2.0)
thor
bourne (1.4.0)
mocha (~> 0.13.2)
builder (3.0.4)
childprocess (0.3.9)
ffi (~> 1.0, >= 1.0.11)
coderay (1.0.9)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.6.2)
database_cleaner (0.9.1)
debug_inspector (0.0.2)
devise (2.2.3)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
diff-lcs (1.2.2)
ember-auth-source (3.0.1)
ember-rails (~> 0.10)
ember-data-source (0.0.5)
ember-source
ember-source (1.0.0.rc2.0)
handlebars-source (>= 1.0.0.rc3, < 1.0.0.rc4)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
fabrication (2.6.4)
ffi (1.6.0)
formatador (0.2.4)
guard (1.7.0)
formatador (>= 0.2.4)
listen (>= 0.6.0)
lumberjack (>= 1.0.2)
pry (>= 0.9.10)
thor (>= 0.14.6)
guard-rspec (2.5.2)
guard (>= 1.1)
rspec (~> 2.11)
guard-spork (1.5.0)
childprocess (>= 0.2.3)
guard (>= 1.1)
spork (>= 0.8.4)
haml (4.0.1)
tilt
haml-rails (0.4)
actionpack (>= 3.1, < 4.1)
activesupport (>= 3.1, < 4.1)
haml (>= 3.1, < 4.1)
railties (>= 3.1, < 4.1)
handlebars-source (1.0.0.rc.3)
has_scope (0.5.1)
hike (1.2.1)
i18n (0.6.1)
inherited_resources (1.4.0)
has_scope (~> 0.5.0)
responders (~> 0.9)
journey (1.0.4)
jquery-rails (2.2.1)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.7.7)
launchy (2.2.0)
addressable (~> 2.3)
letter_opener (1.1.0)
launchy (~> 2.2.0)
listen (0.7.3)
lumberjack (1.0.3)
mail (2.5.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
method_source (0.8.1)
mime-types (1.22)
mocha (0.13.3)
metaclass (~> 0.0.1)
momentjs-rails (2.0.0.1)
railties (>= 3.1)
multi_json (1.7.2)
orm_adapter (0.4.0)
polyglot (0.3.3)
pry (0.9.12)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
pry-rails (0.2.2)
pry (>= 0.9.10)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.13)
actionmailer (= 3.2.13)
actionpack (= 3.2.13)
activerecord (= 3.2.13)
activeresource (= 3.2.13)
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.4)
rb-fchange (0.0.6)
ffi
rb-fsevent (0.9.3)
rb-inotify (0.9.0)
ffi (>= 0.5.0)
rdoc (3.12.2)
json (~> 1.4)
responders (0.9.3)
railties (~> 3.1)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.0)
rspec-rails (2.13.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
sass (3.2.7)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
shoulda (3.4.0)
shoulda-context (~> 1.0, >= 1.0.1)
shoulda-matchers (~> 1.0, >= 1.4.1)
shoulda-context (1.1.0)
shoulda-matchers (1.5.6)
activesupport (>= 3.0.0)
bourne (~> 1.3)
simple_form (2.1.0)
actionpack (~> 3.0)
activemodel (~> 3.0)
slop (3.4.4)
spork (0.9.2)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.7)
thor (0.18.1)
tilt (1.3.6)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.37)
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
warden (1.2.1)
rack (>= 1.0)
PLATFORMS
ruby
DEPENDENCIES
active_model_serializers!
annotate
awesome_print
bcrypt-ruby
better_errors
binding_of_caller
bootstrap-sass
bourbon
coffee-rails
database_cleaner
devise
ember-auth-rails!
ember-rails!
ember-source (~> 1.0.0.rc2)
fabrication
guard-rspec
guard-spork
haml-rails
inherited_resources
jquery-rails
letter_opener
momentjs-rails
pry
pry-rails
rails (= 3.2.13)
rb-fchange
rb-fsevent
rb-inotify
rspec-rails
sass-rails
shoulda
simple_form
spork
sqlite3
uglifier
Thanks, I'll look into it.
Sorry, my oversight. Plesae post your Auth.Config
also.
Auth.Config.reopen
tokenCreateUrl: '/users/sign_in'
tokenDestroyUrl: '/users/sign_out'
tokenKey: 'auth_token'
idKey: 'user_id'
userModel: App.User
rememberMe: true
rememberTokenKey: 'remember_token'
rememberPeriod: 14 # days
authRedirect: true
smartSignInRedirect: true
signInRoute: 'sign_in'
signOutRoute: 'sign_out'
signInRedirectFallbackRoute: 'newsfeed'
signOutRedirectFallbackRoute: 'index'
Auth.on 'signInError', ->
switch Auth.jqxhr.status
when 400
alert 'Please fill in both "login" and "password" fields'
when 401
alert 'Incorrect login/password combination!'
else
alert 'Something went wrong :-/'
Thanks.
Bug confirmed. Finding a fix now.
Thanks a lot @kevinansfield for this bug report! v3.0.2
has been released now, which contains the fix.
Awesome, thank you for your great work on this library!
You know, I'm just sharing what I had written for use in my own ember app. :-)
I've just upgraded to 3.0.1 but now whenever I try to log in I get the following error server-side:
MultiJson::LoadError at /users/sign_in
App backtrace
Full backtrace