Railsは初めてで、この小さなログインコントローラーを作成しました。
def create
username = params[:user].downcase
user = User.where("username = ? OR email = ?", username, username)[0]
if user and user.check_password(params[:password], user.password, user.salt)
cookies[:auth] = user.auth
redirect_to root_url
else
flash.now.notice = 'Login failed'
render 'new'
end
end
これが安全かどうか疑問に思っていますか、それともユーザー名にサニタイズを追加する必要がありますか?