# Elegant Registration / Log in fix

**URL:** <https://www.ruby-forum.com/t/elegant-registration-log-in-fix/191320>\
**Category:** Rails\
**Created:** [July 9, 2010, 3:48pm UTC](https://www.ruby-forum.com/t/elegant-registration-log-in-fix/191320 "2010-07-09T15:48:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@DanC](https://www.ruby-forum.com/u/DanC)\
**Post date:** [July 9, 2010, 3:48pm UTC](https://www.ruby-forum.com/t/elegant-registration-log-in-fix/191320/1 "2010-07-09T15:48:08Z")

</div>

Hi,

I have an app which allows users to register using two different email  
address suffixes only which identifies them as being from a certain  
organisation.

Let’s call them @abcd.co.uk and @abcdefg.co.uk

The shorter version is just a contraction of the longer version and  
are interchangeable for the users in their day to day email activity.  
The problem is that some people register with the long form and then  
try and log in using the short form.

This causes a headache for the admin who gets unnecessary emails.

What is the most Rails way to deal with this at log in and catch the  
users error automatically but still allowing log in? i.e. make the app  
insensitive to which email gets used for login / registration etc.

The app uses Resftul\_authentication plugin

Thanks,

Dan

---

<div class="post-metadata">

**Author:** ![DanC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@DanC](https://www.ruby-forum.com/u/DanC)\
**Post date:** [July 9, 2010, 5:14pm UTC](https://www.ruby-forum.com/t/elegant-registration-log-in-fix/191320/2 "2010-07-09T17:14:15Z")

</div>

I don’t use Resftul\_authentication, but without knowing the details of  
it personally  
I’d use a before\_filter in ApplicationController (or SignupController  
and  
LoginController) to set params[:email] (or whatever) to the shorter  
email  
(gsub to replace the long one with the short one).

There may be a better way with Restful\_authentication and you’ll need to  
find out the param names you need to change the values for, but that may  
point you in a direction to get it working…

Cheers,

Andy

–  
Andy J.  
[http://andyjeffries.co.uk/](http://andyjeffries.co.uk/)#rubyonrails #mysql #jquery  
Registered address: 64 Sish Lane, Stevenage, Herts, SG1 3LS  
Company number: 5452840
