I am using active admin and devise in rails 4. When i am logging out to the active admin user it will automatically logging out to the devise user also.
Any help would be appreciated....
Thanks
You could set a custom logout path in your active_admin.rb file. Look for the line with config.logout_link_path
Related
I am using cancan gem with rails3. Here I have same log in form for all roles. I have a admin section. Normal authentication check user log in or not but not check his role admin or not.
So normal user can see admin pages using admin url (myapp/com/admin/users), how to authenticate ?
Thanks
Prasad
As far as I know CanCan is not for authentication but for authorization
Use something like Devise gem for authentication. And CanCan's ability class to enforce authorization.
You can also manually check if a user is permitted to perform an action using a before_filter hook.
I am using devise for authentication in my Rails 3.2.6 app. I had password confirmation first but now I want to remove it. How to go about that?
You just need to remove the password_confirmation field from your form.
More info in this answer.
Does anyone know how to integrate Active Admin with Authlogic (I'm using authlogic_ldap_authenticatable gem to authenticate to AD)? I know Active Admin uses Devise, so what changes should I make to Active Admin for it to work with Authlogic? Thanks in advance.
Note: I used Rails 3.2.8 and Active Admin 0.5.0 when I did this.
Here's one way to do it:
First, update Gemfile by adding gem activeadmin, and run the rails generate active_admin:install. These are as instructed in the Active Admin README.
Typically there's already a User model that uses Authlogic, and if you plan to use that, remove all files for the new Admin User that Active Admin has generated by default:
db/migrate/*_create_admin_users.rb (migration file)
app/models/admin_user.rb
spec/models/admin_user_spec.rb
Remove Devise-specific files:
config/locales/devise.en.yml
config/initializers/devise.rb
Remove the Devise reference in config/routes.rb.
There's a generated file app/admin/admin_user.rb. You can reuse it by renaming the file to user.rb, register User in it instead of AdminUser, and remove indices on columns specific to Devise. Or, you can just delete the file altogether, and just create your own from scratch.
Update the following in your Active Admin config (see config/initializers/active_admin.rb):
config.authentication_method
config.current_user_method
config.logout_link_path
The default config.authentication_method is :authenticate_admin_user. Set it to whatever before filter method you use for requiring an admin user, e.g. :require_admin. The default config.current_user_method is :current_admin_user. A typical Rails app that uses Authlogic might have a :current_user method for this. And config.logout_link_path should be set to your path for logging out, e.g. :logout_path.
You may need to modify these instructions according to your case.
I've built a RESTful API with Ruby On Rails, and now I good like to know whether the user's credentials received by POST are valid or not, using Devise.
Any ideas?
Devise - getting started should set you up.
EDIT:
Devise, by default, validates users by their email and password. If you want to add validation by username, refer this wiki
Basically, you need to add username to the model and make it 'attr-accessible'
Devise sets up paths for user sign-up, sign-in and sign-out, etc.
Refer devise asciicast for these path helpers.
To write controller tests, refer to this wiki for details.
EDIT:
Sorry for not understanding your requirements. Here is how to find user from credentials. This you can use from your service to validate user.
My rails 3.0.3 app uses devise gem (1.1.5) for authentication and before I wasn't using the :registerable module. I have since added that to enable users to sign up. I then implemented my own registration controller which extends Devise::RegistrationsController. Now when I visit the url /users/sign_up. I get "Missing template error" because rails doesn't find the registration views under app/views. I had generated the devise views using rails generate devise_views which means that my registration views are under app/views/devise/. When I copy the views to app/views/ folder it works. This doesn't seem very DRY. Is there a way of telling rails to use the views in app/views/devise?
thanks,
Kibet.
The easiest way is to add a line in \config\application.rb
config.paths['app/views'] << "app/views/devise"