# Why no login modules?

**URL:** <https://www.ruby-forum.com/t/why-no-login-modules/97765>\
**Category:** Rails\
**Created:** [January 26, 2006, 9:13pm UTC](https://www.ruby-forum.com/t/why-no-login-modules/97765 "2006-01-26T21:13:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kylemathews](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/51bf81/32.png) [@kylemathews](https://www.ruby-forum.com/u/kylemathews)\
**Post date:** [January 26, 2006, 9:13pm UTC](https://www.ruby-forum.com/t/why-no-login-modules/97765/1 "2006-01-26T21:13:57Z")

</div>

Given all of the login/component controversy, and the multiple  
efforts, I’ve really been surprised that no one AFAIK has taken a  
module approach to logins / authentication. It seems that the  
generator and engines approaches are the way to go.

I assume this mentality is due to the desire to include login pages,  
password recovery pages, etc. But what if a plugin usage looked like  
this:

class MyUser \< ActiveRecord::Base  
acts\_as\_user :login =\> “username\_field”, :password =\>  
“my\_password\_field”  
use\_acl :roles  
end

The plugin has no ambitions of handling views, but only doing model  
tasks, such as salting the password, and possibly providing access to  
roles. Its easy to update (no generated code), and easy to apply  
because it doesn’t place any requirements on the schema or views.  
Maybe it could also provide:

class MyController \< ActionController::Base  
authenticate\_against :my\_user, :except =\> [“index”, “login”]  
end

Goals include simplicity, configurability, no generated code, no view  
code, loose coupling to the db schema. Any feedback as to the merits  
of the approach?

–  
Kyle M.  
Chief Technologist  
E Factor Media // FN Interactive  
removed\_email\_address@domain.invalid  
1-866-263-3261

---

<div class="post-metadata">

**Author:** ![kylemathews](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/51bf81/32.png) [@kylemathews](https://www.ruby-forum.com/u/kylemathews)\
**Post date:** [January 26, 2006, 10:23pm UTC](https://www.ruby-forum.com/t/why-no-login-modules/97765/2 "2006-01-26T22:23:38Z")

</div>

On 1/26/06, Kyle M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> acts\_as\_user :login =\> “username\_field”, :password =\> “my\_password\_field”  
> authenticate\_against :my\_user, :except =\> [“index”, “login”]  
> removed\_email\_address@domain.invalid  
> 1-866-263-3261

We tried this at RubyConf this year actually (and freaked David out  
when showing him what we were working on). We had an act for the  
model (it’s where the acts\_as\_authenticated name came from) with  
plugins for encryption schemes (KirinDave hacked up a nice rot13  
one!). We had controller macros for setting up the various actions  
too. It wasn’t that tough to write really.

The problem was writing all the configuration options. It became  
apparent that we were just substituting the already-clean ruby code  
for our own configuration syntax (setting field names, validations,  
etc). Rails is already easy enough to write, and I didn’t feel liking  
coming up with something else for the Rails developer to learn in  
order to use the plugin. I then took Tobi’s expert example and  
rewrote everything as a straightforward generator.

Anyways, good luck 🙂

–  
Rick O.  
[http://techno-weenie.net](http://techno-weenie.net)
