before_filter :require_administrator, :only => [:set_status, :delete, :list]
before_filter :lookup_this_user, :only => [:set_status, :delete]
- filter_parameter_logging :password, :pass_crypt, :pass_crypt_confirmation
-
- cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete], :unless => STATUS == :database_offline
+ cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete]
def terms
@legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || DEFAULT_LEGALE
if params[:user] and params[:user][:openid_url] and @user.pass_crypt.empty?
# We are creating an account with OpenID and no password
# was specified so create a random one
- @user.pass_crypt = ActiveSupport::SecureRandom.base64(16)
+ @user.pass_crypt = SecureRandom.base64(16)
@user.pass_crypt_confirmation = @user.pass_crypt
end
elsif @user.terms_agreed?
# Already agreed to terms, so just show settings
redirect_to :action => :account, :display_name => @user.display_name
- elsif params[:user] and params[:user][:openid_url]
+ elsif params[:user] and params[:user][:openid_url] and not params[:user][:openid_url].empty?
# Verify OpenID before moving on
session[:new_user] = @user
openid_verify(params[:user][:openid_url], @user)
end
else
# Not logged in, so redirect to the login page
- redirect_to :action => :login, :referer => request.request_uri
+ redirect_to :action => :login, :referer => request.fullpath
end
end
end
def save
@title = t 'user.new.title'
- if Acl.find_by_address(request.remote_ip, :conditions => {:k => "no_account_creation"})
+ if Acl.address(request.remote_ip).where(:k => "no_account_creation").exists?
render :action => 'new'
elsif params[:decline]
if @user
@user.languages = request.user_preferred_languages
@user.terms_agreed = Time.now.getutc
@user.terms_seen = true
+ @user.openid_url = nil if @user.openid_url and @user.openid_url.empty?
if @user.save
+ flash[:piwik_goal] = PIWIK_SIGNUP_GOAL if defined?(PIWIK_SIGNUP_GOAL)
flash[:notice] = t 'user.new.flash create success message', :email => @user.email
- Notifier.deliver_signup_confirm(@user, @user.tokens.create(:referer => session.delete(:referer)))
+ Notifier.signup_confirm(@user, @user.tokens.create(:referer => session.delete(:referer))).deliver
session[:token] = @user.tokens.create.token
redirect_to :action => 'login', :referer => params[:referer]
else
def account
@title = t 'user.account.title'
- @tokens = @user.oauth_tokens.find :all, :conditions => 'oauth_tokens.invalidated_at is null and oauth_tokens.authorized_at is not null'
+ @tokens = @user.oauth_tokens.authorized
if params[:user] and params[:user][:display_name] and params[:user][:description]
@user.display_name = params[:user][:display_name]
@title = t 'user.lost_password.title'
if params[:user] and params[:user][:email]
- user = User.find_by_email(params[:user][:email], :conditions => {:status => ["pending", "active", "confirmed"]})
+ user = User.visible.where(:email => params[:user][:email]).first
if user
token = user.tokens.create
- Notifier.deliver_lost_password(user, token)
+ Notifier.lost_password(user, token).deliver
flash[:notice] = t 'user.lost_password.notice email on way'
redirect_to :action => 'login'
else
if token
token.destroy
end
- session[:token] = nil
+ session.delete(:token)
end
- session[:user] = nil
+ session.delete(:user)
session_expires_automatically
if params[:referer]
redirect_to params[:referer]
def confirm_resend
if user = User.find_by_display_name(params[:display_name])
- Notifier.deliver_signup_confirm(user, user.tokens.create)
+ Notifier.signup_confirm(user, user.tokens.create).deliver
flash[:notice] = t 'user.confirm_resend.success', :email => user.email
else
flash[:notice] = t 'user.confirm_resend.failure', :name => params[:display_name]
def make_friend
if params[:display_name]
name = params[:display_name]
- new_friend = User.find_by_display_name(name, :conditions => {:status => ["active", "confirmed"]})
+ new_friend = User.active.where(:display_name => name).first
friend = Friend.new
friend.user_id = @user.id
friend.friend_user_id = new_friend.id
unless @user.is_friends_with?(new_friend)
if friend.save
flash[:notice] = t 'user.make_friend.success', :name => name
- Notifier.deliver_friend_notification(friend)
+ Notifier.friend_notification(friend).deliver
else
friend.add_error(t('user.make_friend.failed', :name => name))
end
def remove_friend
if params[:display_name]
name = params[:display_name]
- friend = User.find_by_display_name(name, :conditions => {:status => ["active", "confirmed"]})
+ friend = User.active.where(:display_name => name).first
if @user.is_friends_with?(friend)
Friend.delete_all "user_id = #{@user.id} AND friend_user_id = #{friend.id}"
flash[:notice] = t 'user.remove_friend.success', :name => friend.display_name
failed_login t('user.login.auth failure')
end
else
+ # Guard against not getting any extension data
+ sreg = Hash.new if sreg.nil?
+ ax = Hash.new if ax.nil?
+
# We don't have a user registered to this OpenID, so redirect
# to the create account page with username and email filled
# in if they have been given by the OpenID provider through
session[:user] = user.id
session_expires_after 1.month if session[:remember_me]
- target = params[:referer] || url_for(:controller => :site, :action => :index)
+ target = session[:referer] || url_for(:controller => :site, :action => :index)
# The user is logged in, so decide where to send them:
#
flash.now[:notice] = t 'user.account.flash update success confirm needed'
begin
- Notifier.deliver_email_confirm(user, user.tokens.create)
+ Notifier.email_confirm(user, user.tokens.create).deliver
rescue
# Ignore errors sending email
end
if params[:display_name]
redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name]
else
- redirect_to :controller => 'user', :action => 'login', :referer => request.request_uri
+ redirect_to :controller => 'user', :action => 'login', :referer => request.fullpath
end
elsif not @user
- redirect_to :controller => 'user', :action => 'login', :referer => request.request_uri
+ redirect_to :controller => 'user', :action => 'login', :referer => request.fullpath
end
end