heartcombo / devise Goto Github PK
View Code? Open in Web Editor NEWFlexible authentication solution for Rails with Warden.
Home Page: http://blog.plataformatec.com.br/tag/devise/
License: MIT License
Flexible authentication solution for Rails with Warden.
Home Page: http://blog.plataformatec.com.br/tag/devise/
License: MIT License
Perhaps these are all valid, but this seems to lack clarity as to how the email sender should be set. Here are three different stated ways that the sender can be set...
On command line after "script/generate devise Model"...
Setup default sender for mails.In config/environment.rb:
Notifier.sender = "[email protected]"
README - development environment
DeviseMailer.sender = "[email protected]"
initializers/devise.rb after "script/generate devise_install"
config.mail_sender = "[email protected]"
Best Regards,
David Baldwin
If you use the devise.rb initializer and enable the commented out options, script/generate fails. Here's a stack trace:
script/generate
/Users/rich/dev/42rooms/config/initializers/devise.rb:6: undefined method pepper=' for Devise:Module (NoMethodError) from /Users/rich/dev/42rooms/vendor/gems/devise-0.4.0/lib/devise.rb:18:in
setup'
from /Users/rich/dev/42rooms/config/initializers/devise.rb:3
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:145:in load_without_new_constant_marking' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:145:in
load'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in new_constants_in' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:145:in
load'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:622:in load_application_initializers' from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:621:in
each'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:621:in load_application_initializers' from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:176:in
process'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in send' from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in
run'
from /Users/rich/dev/42rooms/config/environment.rb:4
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
require'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/commands/generate.rb:1
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
require'
from script/generate:3
Hey José,
Here comes the issue for your records.
Feature description: It would be nice to add support for encryptions of different solutions to allow people to migrate production applications to Devise.
Here's my implementation: http://github.com/mhfs/devise/
Currently supporting Clearance, Authlogic and Restful-Authentication.
Discussion in mailing list: http://groups.google.com/group/plataformatec-devise/browse_thread/thread/fb9c7f6b5bc02959
Thanks,
Marcelo
I've attempted to use devise along side jnunemaker's mongo_mapper and I continue to run into an issue where my model:
class User
include MongoMapper::Document
devise :all
end
results in:
method_missing :NoMethodError: undefined method 'devise_modules' for User:Class
Any hints on how to get it to properly extend Devise::Models ? My ruby meta-fu is weak!
Isn't the word "authenticatable" rather than "authenticable". I'm not sure authenticable is actually a word. Maybe that is how everyone thinks it is spelled so it doesn't matter.
Best Regards,
David Baldwin
for sign in page.
DataMapper.new blow up if you pass in a nil
suggesting fix
# Build a devise resource without setting password and password confirmation fields.
def build_resource
self.resource ||= begin
attributes = params[resource_name].try(:except, :password, :password_confirmation)
resource_class.new(attributes || {})
end
end
I had to put this on my User model cause confirm_within = 0.days does not seem to work properly
def confirmation_period_valid?
false
end
By the way, the intuitive use of confirmable imho is make it 0.days. Normally sites do not enable you to login until you click on the confirmation link. The documentation says the default confirm_within is nil but it does not seem to be working properly. One more thing, I would change the name of the setting:
config.signup_allowed_without_confirming_period = 2.days
or something, you get the idea.
Perhaps it would be helpful to have flexible views for different Devise resources (users, admins, etc.). For example, an admin login form might need to be very different from a user sign-up page, yet both views are currently called from SessionsController#new
which renders controllers/views/sessions/new.html.erb
. It would be really useful to be able to render controllers/views/sessions/admins/new.html.erb
, or controllers/views/sessions/users/new.html.erb
, or some other specified view.
For now, we can include conditional logic in controllers/views/sessions/new.html.erb
(e.g., if we're dealing with users, render form x, else render form y for admins), but this makes for a brittle view. Is there currently a cleaner way to do this? Or might this kind of view customization be a useful feature to add?
nt
Hi plataformatec,
Devise has support for namespaces?
My application have authentication only into admin scope and I want to use Devise for that.
I tried this:
ActionController::Routing::Routes.draw do |map| map.namespace 'admin' do |admin| admin.devise_for :users end end
And I get into rake routes:
(in /home/sobrinho/projetos/xxx) new_user_session GET /admin/users/sign_in {:action=>"new", :controller=>"admin/sessions"} user_session POST /admin/users/sign_in {:action=>"create", :controller=>"admin/sessions"} destroy_user_session GET /admin/users/sign_out {:action=>"destroy", :controller=>"admin/sessions"}
Well, admin/sessions doesn't exist. Then i renamed route to use sessions controller:
ActionController::Routing::Routes.draw do |map| map.namespace 'admin' do |admin| admin.devise_for :users, :controller => 'sessions' end end
But i get
Unknown actionerror when i access login page.
Haven't support or i'm doing something wrong?
the exception ActiveRecord::RecordNotFound is shown when the register no more exist. and should redirect to login page.
FIX:
The following changes since commit 05678e7:
José Valim (1):
Added support to config.default_url_options.
are available in the git repository at:
[email protected]:ramon/devise.git master
Ramon Soares (2):
fix record not found failure in recovery session
failure_app logout with scope now
lib/devise/failure.rb | 2 ++
lib/devise/warden.rb | 6 +++++-
2 files changed, 7 insertions(+), 1 deletions(-)
Hi!
I have got following error on user.save:
undefined method `find_template' for []:Array
Rails 2.3.4.
Also I did script/generate devise_views
before saving users.
Backtrace:
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:582:in candidate_for_layout?' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/layout.rb:240:in
pick_layout'
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:566:in render' /usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:553:in
render_message'
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:493:in create!' /usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:452:in
initialize'
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:395:in new' /usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:395:in
method_missing'
/usr/lib/ruby/gems/1.8/gems/devise-0.5.5/lib/devise/models/confirmable.rb:59:in send_confirmation_instructions' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:178:in
send'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:178:in evaluate_method' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:166:in
call'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:93:in run' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in
each'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in send' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in
run'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:276:in run_callbacks' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/callbacks.rb:344:in
callback'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/callbacks.rb:267:in create' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:2867:in
create_or_update_without_callbacks'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/callbacks.rb:250:in create_or_update' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:2538:in
save_without_validation'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:1078:in save_without_dirty' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/dirty.rb:79:in
save_without_transactions'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:229:in send' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:229:in
with_transaction_returning_status'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in transaction' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:182:in
transaction'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:228:in with_transaction_returning_status' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:196:in
save'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:208:in rollback_active_record_state!' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:196:in
save'
I have generated an empty Rails 2.3.4 app using PostgreSQL. After adding the exact same config.gem statements from the example devise app, some rake tasks and most of the script/* files are broken. I've created a gist with any relevant info I could think of. Please let me know if you'd like me to try anything or provide other information.
Given I am signed in
When I update my email address
Then a confirmation email should be sent
And I should be on my account page
And I should see a message "A confirmation email has been sent to your new email address. Your old email address, {resource.email}, is still active until you confirm the new one."
When I follow the link in the confirmation email
Then I should be on my account page
This is a bit more complicated, but I think it's best practice. The User model will need a :pending_email attribute. You could go a bit further and add something like this in a Devise-generated resource show view:
-if resource.pending_email
You have requested to change your email address to {resource.pending_email}. An email has been sent there to make sure it is a valid address.
= link_to 'Resend confirmation email', ...
= link_to 'Cancel request', ...
Having all this by right out the box would be beautiful!
This kind of route will break url_for parser in topic function:
map.user_root 'admin/dashboard', :controller => 'admin/dashboard', :path_prefix => '/:locale'
Hi everyone,
I installed the latest devise gem (0.4.1) but script/generate devise_install results in the following error:
$ script/generate devise_install
Couldn't find 'devise_install' generator
I wonder whether this is only a problem on my side, or if the generator is missing from the gem ...?
Best regards
Martin Eisenhardt
If User inherits from People, a Person can't be saved because devise adds :null => false on several User attributes, which are only for User, not Person. Removing :null => false works fine.
ruby script/generate devise Model
rake db:migrate
email field not created in the database;
rake aborted!
Mysql::Error: Key column 'email' doesn't exist in table: CREATE UNIQUE INDEX `index_
I want it to simply be '/login', and '/logout'
I managed to do so by adding these to the routes file
map.login 'login', :controller => :sessions, :action => :new, :conditions => { :method => :get }
map.login 'login', :controller => :sessions, :action => :create, :conditions => { :method => :post }
map.logout 'logout', :controller => :sessions, :action => :destroy
But I still have a problem with the before_filter :authenticate_user! where it still redirects the user to 'http://localhost:3000/users/sign_in?unauthenticated=true'.
I would really appreciate it if you can tell me how to override the login url. Thanks.
It would be nice to have something like "last_login_at" and "last_login_from" (client IP) in User model or a hook or a filter in the session controller that allows to populate them prperly.
Thanks in advance
store_#{scope}location
redirect#{scope}back_or_to
sign_in#{scope}
I'm sure I'm doing something wrong, but I can't figure out what. Please help! :)
This works fine in my browser, but fails in my tests. Do I need to include some kind of test helper or something?
The test: http://pastie.org/708343
I'm getting the following when trying to create a new user:
NoMethodError (undefined method `find_template' for []:Array):
devise (0.3.0) lib/devise/models/confirmable.rb:59:in `send_confirmation_instructions'
Hello,
when trying do run an application using devise on heroku (www.heroku.com) I seem to be having some problems, namely with the controller "confirmations", action "show" (when I go to confirm a password in an email).
NoMethodError (undefined method `one?' for #«Array:0x2ac12c27d860»): devise (0.5.4) lib/devise/controllers/filters.rb:129:in `sign_in_and_redirect' devise (0.5.4) app/controllers/confirmations_controller.rb:27:in `show' warden (0.6.3) lib/warden/manager.rb:84:in `call' warden (0.6.3) lib/warden/manager.rb:83:in `catch' warden (0.6.3) lib/warden/manager.rb:83:in `call' /home/heroku_rack/lib/static_assets.rb:9:in `call' /home/heroku_rack/lib/last_access.rb:25:in `call' /home/heroku_rack/lib/date_header.rb:14:in `call'
As I gather, the problem seems to be that heroku is using ruby version 1.8.6
http://docs.heroku.com/technologies
which apparently doesn't support the Enumerable::one? method.
Maybe if this method call could be replaced with something else, not just for heroku, but backwards compatibility with 1.8.6 in general, it's still a widely used ruby version.
Thanks,
Tomislav Car
Perhaps this would allow subclassing Devise controllers in order to override their default methods. For example, suppose we wanted the SessionsController#destroy
action to redirect to the admin_root_path
rather than the root_path
. We would then want to create the app/controllers/sessions_controller.rb
file like so:
class SessionsController < Devise::SessionsController
def destroy
set_flash_message :success, :signed_out if signed_in?(resource_name)
sign_out(resource_name)
redirect_to admin_root_path
end
end
Or is there some other way to override the default SessionsController
behavior?
There is a bug in Rails Engines that puts the engine yml with higher priority then the application yml, being impossible to overwrite the messages. A fix would be to include the yml file by hand and not use engines thing.
script/generate formtastic
/Library/Ruby/Gems/1.8/gems/devise-0.1.0/lib/devise/controllers/filters.rb:72: undefined method mappings' for Devise:Module (NoMethodError) from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:380:in
load_without_new_constant_marking'
It would be nice to have pretty URL for recoverable and confirmable strategies routes.
As is:
"/users/verification?confirmation_token=MyHash"
Nice to have:
"/users/verification/MyHash"
so that confirmation_token is passed in route as param:
"/users/verification/:confirmation_token {:controller=>"users", :action=>"index"}"
Something like:
"map.connect 'users/verification/:confirmation_token', :controller => 'users'"
I don't know how to obtain this, or even if it is possible.
What do you think?
Need mechanism to store and redirect to a requested url and present a custom flash as describe in the scenario below. The first can be done with #authenticate_user! and the second with before_filter :set_flash_and_redirect_to_sign_in, but both are not currently possible.
Given I am a guest
When I follow "Create Post"
I should be on the new user session page
And I should see a message "Please sign in or sign up to create a post"
When I sign in
I should be on the new post page
Wanted to give devise a try instead of authlogic.
I set everything up as desribed in the README, but when trying to start the server or even trying "rake db:migrate" I get the following error:
"uninitialized constant Devise::Encryptors"
Details:
...
rake aborted!
uninitialized constant Devise::Encryptors
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:440:in load_missing_constant' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in
const_missing'
/home/cjk/work/hot/hotrails/vendor/gems/devise-0.5.5/lib/devise.rb:57
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
...
I use devise 0.5.5 and latest version of warden.
Thanks!
nt
(Requested by Martin Eisenhardt in the mailing list)
When I add additional fields in my User model they get completely ignored. I tried creating a new project and using an Account model but the same thing happened. Am I missing something obvious?
apply_schema :encrypted_password, String, :null => null, :limit => Devise::ENCRYPTORS_LENGTH[encryptor]
Devise::ENCRYPTORS_LENGTH is a hash of symbol, but 'encryptor' returns a class so the look up always returns a nil.
I am setting up a site where I want all my users to sign in on their appropriate subdomain. I would like to use the following in my routes:
map.with_options :conditions => { :subdomain => /.+/ } do |workplace|
workplace.devise_for :employees
end
When I do use that I get an error that it doesn't know about the conditions key. anyway I can do something similar?
I'm getting this error with Devise and Bundler. If I run app without Devise, it is okay.
root@ROOT:/c/dev/MUNI/Bakalarka/portfonica$ ruby script/server => Booting Mongrel => Rails 2.3.4 application starting on http://0.0.0.0:3000 c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:440:in `rescue in load_missing_constant': uninitialized constant Controllers::Filters (NameError) from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:436:in `load_missing_constant' from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in `const_missing_with_dependencies' from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/devise-0.4.3/lib/devise/rails/routes.rb:10:in `load_routes_with_devise!' from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:266:in `load!' from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/rails-2.3.4/lib/initializer.rb:537:in `initialize_routing' from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/rails-2.3.4/lib/initializer.rb:188:in `process' from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/rails-2.3.4/lib/initializer.rb:113:in `run' from c:/dev/MUNI/Bakalarka/portfonica/config/environment.rb:5:in `' from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `block in require' from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in' from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require' from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/rails-2.3.4/lib/commands/server.rb:84:in `' from script/server:3:in `require' from script/server:3:in `' root@ROOT:/c/dev/MUNI/Bakalarka/portfonica$
My settings is here:
http://github.com/wycats/bundler/issues#issue/88
I declared nothing Devise anywhere. No configuration in environment.rb or used an initializer. I just specified it in my Gemfile.
Hello,
the latest version I pulled doesn't seem to work properly with Ruby 1.8.6. The problem appears when calling
@user.confirm_within
It works on Devise 0.5.5 and Ruby 1.8.6.
It also works on Devise 0.6.2 and Ruby 1.8.7
But it doesn't work on Devise 0.6.2 and Ruby 1.8.6. Reports that it can't with the method "confirm_within".
Dude, you're fast. Thanks for this awesome gem. I'm working on the oauth strategy now.
please see http://pastie.org/672974 for further informations
Everything was working great in a previous version of Devise but when I upgraded to 0.2.0 authentic_user! now locks up the rails app if the user isn't logged in. Basically what appears to happen is the browser sees the redirect to /users/sign_in?unauthenticated=true and then the app stops responding until it's restarted. When I restart the app I can hit that url directly and login just fine. I suspect the problem is with Warden because Rails isn't outputting anything. Any thoughts? Anybody else seen this issue?
Hi,
I'm using Devise with CouchRest and I would like use Confirmable mixin in my ExtendedDocument. Unfortunately, it fails because CouchRest uses callbacks from Rails 3 and Devise just is compatible with Rails 2 callbacks :(
It's the right way to do it. And it's just a wish... :)
For example, an app that has two forms 'Sign in' and 'Sign up' in the sessions/new view. This view requires the @user instance variable. Currently, Devise has no mechanism to create this. It appears the best we to handle this is to create a generator to add a SessionsController to the app in the same way that we generate the sessions views. Other ideas?
I used to use this function separately with authlogic. It could be referenced with Authlogic::Random.friendly_token
It would be nice if you could do the same for devise so you could reuse this function in other places if you wanted to.
I'm sure I'm doing something wrong, but I can't figure out what. Please help! :)
This works fine in my browser, but fails in my tests. Do I need to include some kind of test helper or something?
The test: http://pastie.org/708343
The password is required in all updates. But if i want change only the email?
maybe a :allow_blank in validate_presence_of :password solve.
from .... /devise-0.1.1/lib/devise/warden.rb:60
Happening with Rails 2.3.4 Devise 0.1.1
I am using the gem bundler stuff but it seems like it's loaded what I'd expect, there's just no Devise::Strategies
Am I missing something to get that module loaded? Am I supposed to manually require those files from the devise lib?
Rename Devise::ActiveRecord to Devise::Models and only include in ActiveRecord if it's really defined.
def confirmed_at?
confirmed_at
end
def confirmation_sent_at?
confirmation_sent_at
end
def remember_token?
remember_token
end
it seems that activerecord defines attribute_method with ? and datamapper doesnt
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.