Short description and motivation.
Add this line to your application's Gemfile:
gem 'account'
-
copy template/devise.rb to your application: admin_engine/config/initializer/devise.rb || config/initializer/devise.rb.
-
Add account gem routes to your app/config/routes.rb.
mount Account::Engine => '/', as: 'account'
Add admin_root or user_root in app/config/routes.rb, for redirection after login. eg:
get '/manager/conferences', to: 'admin/manager/conferences#index', :as => :admin_root
-
for wechat omniauth copy template/omniauth.rb to your application: config/initializer/omniauth.rb.
-
copy db/migrate to your application.
$ rails db:migrate
- add before_action :authenticate_manager, to your ApplicationController
def authenticate_manager
unless admin_signed_in? && (current_admin.role == "admin")
sign_out :admin
redirect_to account.new_admin_session_path, notice: "请使用admin账户访问该页面"
end
end
phone_verification use fetch
, not support IE.
Create config/initializers/account_engine.rb
and put following configurations into it.
I like to put it at admin engine.
# eg.
Account::Engine.custom_routes = true
Account::Engine.admin_modle_devise_setting = [:database_authenticatable]
If you setting custom_routes = ture, then add following to your routes file. I like to put it at admin engine routes file.
Account::Engine.routes.draw do
devise_for :admins, module: 'devise', class_name: "Account::Admin", only: :sessions
end
Contribution directions go here.
The gem is available as open source under the terms of the MIT License.