百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

any_login

> 编程语言
开源

以系统中的任何用户身份登录的简单方法

387 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

以系统中的任何用户身份登录的简单方法

AnyLogin Gem

Description

Demo available on: https://any-login.herokuapp.com (source code for demo https://github.com/igorkasyanchuk/any_login_test)

Video Demo: https://youtu.be/978DlHvufSY

AnyLogin was created to speed up the development process by allowing developers to quickly log in as any user.

Give it a try; if you like it please share AnyLogin with friends. If you have any suggestions please feel free to contact me.

Requirements

Ruby: >= 3.0, Rails: >= 6.1. Pre-configured to work with Devise, Authlogic, Clearance or Sorcery gems.

For Rails User.admins.limit(10), 'moderator' => User.moderators.limit(10), 'user' => User.users.limit(10) } end end


Or another sample:

```ruby
# Initializer: config/initializers/any_login.rb
AnyLogin.setup do |config|
  config.collection_method = :grouped_users
  # to format user name in dropdown list
  config.name_method = :any_login_name
end

# User class: app/models/user.rb
class User < ActiveRecord::Base
  def any_login_name
    [full_name + ' - ' + email + " Domains: #{domains.collect(&:short_code).join(',').presence || 'none'}; Role: #{role}; ID: #{id}", id]
  end

  def self.grouped_users
    Organization.ordered.includes(:employees).inject({}) do |res, org|
      res[org.name] = org.employees.ordered.includes([:domains, :organization])
      res
    end
  end
end

Production

If you want to completely disable gem in production add following code in your config/environments/production.rb file.

ruby
AnyLogin.setup do |config|
  config.enabled = false
end

You can also try to debug your application in production and secure AnyLogin with HTTP_BASIC authentication. See Options sections for more details.

Future Plans

  1. Add tests
  2. Add support for more authentication gems like Devise, Authlogic, Clearance (restful_authentication, monban, letmein)

Contributors

  • @incubus
  • @bbenezech
  • @manastyretskyi
  • @saiqulhaq
  • @zorab47
  • @shivabhusal
  • @eliotsykes
  • @sviatoslav-krupa
  • @daichirata
  • @linshaodongsam
  • @jr180180
  • @vmyts539
  • @rbclark
  • @OskarsEzerins
  • @kyohah

For CI

Update gemspec:

bash
BUNDLE_GEMFILE=./gemfiles/rails_8_0.gemfile bundle

Tests

To setup test apps:

./prepare.sh

and

bundle exec appraisal install

To run tests:

bash

bundle exec appraisal rails-8-0 bundle exec test_devise
bundle exec appraisal rails-8-0 bundle exec test_clearance
bundle exec appraisal rails-8-0 bundle exec test_authlogic
bundle exec appraisal rails-8-0 bundle exec test_sorcery

# or

bundle exec appraisal rails-8-0 bundle exec rails test test/devise/
bundle exec appraisal rails-8-0 bundle exec rails test test/authlogic/
bundle exec appraisal rails-8-0 bundle exec rails test test/clearance/
bundle exec appraisal rails-8-0 bundle exec rails test test/sorcery/

If you want to manually tests open test/rails_apps/devise/ and run BUNDLE_GEMFILE=../../../gemfiles/rails_8_0.gemfile bundle exec rails s and open http://localhost:3000 (and with other gems)

Note: with Devise it can glitch in dummy app so I suggest to connect to real app using:

ruby
  gem 'any_login', path: '../any_login'

Other

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言