At the Forge - Authenticating to a Rails Application
acts_as_authenticated is good enough for many sites as it currently stands. However, there are a number of plugins, suggestions and modifications that you can use with acts_as_authenticated.
For example, many registrations systems want to stop bots from automatically creating user names or e-mail addresses, which can be used to send spam. Thus, it's common for the registration system to ask that users confirm their membership requests via e-mail. So, you enter your information at the site and receive a message that asks you to click on a link. Only after clicking on that link is your account actually activated.
This functionality, although not an obvious part of the core acts_as_authenticated plugin, comes with it and is easy to use. Basically, we use the other generator that comes with acts_as_authenticated. This creates the templates and most of the logic that we need for people to confirm their login status.
There are a wide variety of other things you can do with acts_as_authenticated. For example, you can set it so that passwords are encrypted, but in a way such that it would be reversible. Another common task is to let users change their personal information, such as e-mail addresses and telephone numbers.
This whole discussion of acts_as_authenticated began because I wanted to use OpenID in a Rails application. However, I also wanted to integrate OpenID with an existing authentication mechanism, which brought me to acts_as_authenticated. Now that we have a working, if bare-bones, authentication system on our Web site, we can move on to the next step.
Even if you are not using acts_as_authenticated in your Rails application, it's useful to see how plugins work, how you interact with them and how you can use them to build your Rails application out of parts that have been contributed by other programmers.
Next month, we will look at how we can integrate OpenID into our login system—namely, allowing people to log in using either a user name/password combination or OpenID.
If you're still new to Rails, I strongly recommend The Rails Way by Obie Fernandez. I have found it to be both clear and comprehensive, and one chapter in the book is dedicated to acts_as_authenticated.
There are a number of good resources about acts_as_authenticated on the Web. However, the most comprehensive is the author's Wiki, at technoweenie.stikipad.com/plugins/show/Acts+as+Authenticated.
Reuven M. Lerner, a longtime Web/database developer and consultant, is a PhD candidate in learning sciences at Northwestern University, studying on-line learning communities. He recently returned (with his wife and three children) to their home in Modi'in, Israel, after four years in the Chicago area.
Webinar: 8 Signs You’re Beyond Cron
11am CDT, April 29th
Join Linux Journal and Pat Cameron, Director of Automation Technology at HelpSystems, as they discuss the eight primary advantages of moving beyond cron job scheduling. In this webinar, you’ll learn about integrating cron with an enterprise scheduler.Join us!
|Android Candy: Intercoms||Apr 23, 2015|
|"No Reboot" Kernel Patching - And Why You Should Care||Apr 22, 2015|
|Return of the Mac||Apr 20, 2015|
|DevOps: Better Than the Sum of Its Parts||Apr 20, 2015|
|Play for Me, Jarvis||Apr 16, 2015|
|Drupageddon: SQL Injection, Database Abstraction and Hundreds of Thousands of Web Sites||Apr 15, 2015|
- "No Reboot" Kernel Patching - And Why You Should Care
- DevOps: Better Than the Sum of Its Parts
- Android Candy: Intercoms
- Return of the Mac
- Drupageddon: SQL Injection, Database Abstraction and Hundreds of Thousands of Web Sites
- Designing Foils with XFLR5
- Non-Linux FOSS: .NET?
- Play for Me, Jarvis
- Consent That Goes Both Ways