Sha256: 8d3401a0e22af451ab91452e3ab2e29fba4517449a24adef2cab519c714a2177
Contents?: true
Size: 1.38 KB
Versions: 13
Compression:
Stored size: 1.38 KB
Contents
class PreferencesController < ApplicationController before_filter :check_user layout :admin_layout # TODO: test def list @user = visitor end # TODO: test def change_password @user = User.find(visitor[:id]) # reload to get password if params[:user][:password].strip.size < 6 @user.errors.add('password', 'too short') end if params[:user][:password] != params[:user][:retype_password] @user.errors.add('retype_password', 'does not match new password') end if User.hash_password(params[:user][:old_password]) != @user[:password] @user.errors.add('old_passowrd', 'not correct') end if @user.errors.empty? @user.password = params[:user][:password] if @user.save flash[:notice] = _('password successfully updated') end end end #TODO: test def change_info @user = User.find(visitor[:id]) # reload to get password # only accept changes on the following fields through this interface attrs = {} [:login, :first_name, :name, :time_zone, :lang, :email].each do |sym| attrs[sym] = params[:user][sym] end if @user.update_attributes(attrs) flash[:notice] = _('information successfully updated') session[:lang] = params[:user][:lang] if params[:user][:lang] end end private # TODO: test def check_user if visitor[:id] == 1 page_not_found end end end
Version data entries
13 entries across 13 versions & 1 rubygems