Browse files

finally fixed login/activation procedure

  • Loading branch information...
1 parent 6fbf08c commit 42e5f6f2295553be44b57d6742baa60886f3a076 @localhost localhost committed Feb 10, 2009
View
4 app/controllers/application.rb
@@ -23,10 +23,6 @@ def current_page
@page ||= params[:page].blank? ? 1 : params[:page].to_i
end
- def sanitized_login_name(name)
- name.strip.downcase
- end
-
private
def set_language
View
1 app/controllers/sessions_controller.rb
@@ -8,7 +8,6 @@ def new
def create
reset_session
- params[:login] = sanitized_login_name(params[:login])
self.current_user = current_site.users.authenticate(params[:login], params[:password])
if logged_in?
View
7 app/controllers/users_controller.rb
@@ -22,13 +22,13 @@ def new
def create
cookies.delete :auth_token
- params[:user][:login] = sanitized_login_name(params[:user][:login])
@user = current_site.users.build(params[:user])
@user.save if @user.valid?
+ @user.register! if @user.valid?
unless @user.new_record?
- @user.register!
+ # self.current_user = @user
redirect_back_or_default('/')
- flash[:notice] = "Thanks for signing up!"
+ flash[:notice] = "Thanks for signing up! Please check your Email. You may login as soon, as you activated your account."
else
render :action => 'new'
end
@@ -45,7 +45,6 @@ def edit
end
def update
- params[:user][:login] = sanitized_login_name(params[:user][:login])
@user = admin? ? find_user : current_user
respond_to do |format|
if @user.update_attributes(params[:user])
View
6 app/models/user/validation.rb
@@ -3,6 +3,7 @@ class User
# Virtual attribute for the unencrypted password
attr_accessor :password
+ before_validation :normalize_login_and_email
validates_presence_of :login, :email
validates_presence_of :password, :if => :password_required?
validates_presence_of :password_confirmation, :if => :password_required?
@@ -11,7 +12,6 @@ class User
validates_length_of :login, :within => 3..40
validates_length_of :email, :within => 3..100
validates_uniqueness_of :login, :email, :scope => :site_id
- before_save :downcase_email_and_login
before_save :encrypt_password
before_create :set_first_user_as_admin
@@ -50,8 +50,10 @@ def set_first_user_as_admin
self.admin = true if site and site.users.size.zero?
end
- def downcase_email_and_login
+ def normalize_login_and_email
login.downcase!
+ login.strip!
email.downcase!
+ return true
end
end
View
2 app/views/users/edit.html.erb
@@ -25,5 +25,5 @@
<% form_for :user, :url => user_path(@user), :html => { :method => :put } do |f| -%>
<%= render :partial => "contact_info", :locals => { :settings => f } %>
- <%= submit_tag I18n.t('txt.views_users.update_profile', :default => 'Update profile') %> <%= I18n.t 'txt.or', :default => 'or' %> <%= link_to(I18n.t('txt.cancel', :default => 'Cancel'), user_path) %>
+ <%= submit_tag I18n.t('txt.views_users.update_profile', :default => 'Update profile') %> <%= I18n.t 'txt.or', :default => 'or' %> <%= link_to(I18n.t('txt.cancel', :default => 'Cancel'), user_path(@user)) %>
<% end -%>

0 comments on commit 42e5f6f

Please sign in to comment.