Manage users and admins with Devise and Omniauth-Facebook.
Make avaiable to your users for loggin with Devise or Facebook, and manage them and your admins. Each admin is related to roles with Rolify, and manages authorization with CanCan.
-
Add to your gemfile:
gem 'simple_user'
-
Run
bundle
-
Execute:
rails generate simple_user:install
-
Run migrations:
rake db:migrate
-
Run seeds:
rake db:seed
-
Add to your routes.rb:
mount SimpleUser::Engine => "/simple_user", :as => "simple_user"
-
Add to your application.js:
//= require simple_user/application
-
Add before filters
banned?
andset_user_return_to
(check /lib/simple_user/concerns/controllers/application_controller.rb if you want to override these methods) -
Watch the test/dummy for an example of the links
-
Remember add
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
to your config/application.rb, and change the host in production
Example for users:
<% unless user_signed_in? %> <%=link_to "Login", simple_user.new_user_session_path %> <%= link_to "Login with Facebook", "/simple_user/auth/facebook", id: "sign_in" %> <% else %> <%= link_to "Welcome, #{current_user.username}", simple_user.edit_user_registration_path %> <%= link_to "Log out", simple_user.destroy_user_session_path, method: :delete, id: "sign_out" %> <% end %>
Example for admins:
<% unless admin_user_signed_in? %> <%=link_to "Login", simple_user.new_admin_user_session_path %> <% else %> <%= link_to "Welcome, Admin: #{current_admin_user.username}", simple_user.edit_admin_user_registration_path %> <% if can? :manage, SimpleUser::AdminUser %> <%= link_to "Manage Admins", simple_user.admin_users_path %> <% end %> <% if can? :manage, SimpleUser::User %> <%= link_to "Manage Users", simple_user.users_path %> <% end %> <%= link_to "Log out", simple_user.destroy_admin_user_session_path, method: :delete, id: "sign_out" %> <% end %>
-
Integrate Twitter
-
Ingrate Google
-
Remove unnecessary files and codes (rake task, omniauth, …)