From ab9fbd774c6f1799f7244ae24943d0e89394b070 Mon Sep 17 00:00:00 2001 From: "Aleksandr O. Levchuk" Date: Sun, 16 Sep 2007 10:45:57 -0700 Subject: [PATCH] Fix: User Registration Bug (caused by new SAFE_EMAIL) Fixed and De-coupled the bug. --- app/controllers/login_controller.rb | 13 ++++++++++--- config/mwamko_constants.rb | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb index 7268d17..bcec867 100644 --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -48,16 +48,23 @@ class LoginController < ApplicationController unless params[:user][:email] =~ SAFE_EMAIL return show_error("Please Enter a Valid Email") else - email = $1 - username = $2 + # De-coupled from the details of the SAFE_EMAIL regular expression + if params[:user][:email] =~ /^([^@]+)@(.+)$/ + username = $1 + hostname = $2 + email = "#{$1}@#{$2}" + else + raise "Could not split the email into the 2 parts." + end end + return show_error("Your Email is Not Authorized") unless is_allowed?(email) new_password = PasswordGen.generate_pronounceable - new_user = User.new(:name => username, + new_user = User.new(:name => email, :password => new_password, :password_confirmation => new_password) diff --git a/config/mwamko_constants.rb b/config/mwamko_constants.rb index 274a9e4..71efbe1 100644 --- a/config/mwamko_constants.rb +++ b/config/mwamko_constants.rb @@ -1,3 +1,6 @@ +# Mwamko has to be restarted when this file is changed +# Run: ./script/mwamko restart + module MwamkoConstants SCRIPT_DIR = File.dirname(File.expand_path(__FILE__)) SCRIPT_NAME = $0.split('/')[-1] -- 2.11.4.GIT