嘿家伙我创建了一些自定义身份验证感谢railscasts.com但我有点卡住,因为我需要限制我的用户编辑其他用户的配置文件。需要帮助自定义身份验证
这里是我的authenticate_user和CURRENT_USER方法:
private
def current_user
@current_user ||= User.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]
end
def authenticate_user!
if current_user.nil?
redirect_to login_url, :alert => "You must first log in to access this page"
end
end
下面是我的UsersController的的before_filter:
before_filter :authenticate_user!, :only => [:edit, :update, :destroy]`
编辑:固定它归功于alock27。
我不得不修改我的users_controller和修改编辑动作如下:
@user = User.find(params[:id]
redirect_to root_url unless current_user == @user
你在使用Devise吗? – efoo
不,它是一个使用railscasts.com的教程构建的自定义身份验证系统:p – imjp