diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6a6118b..1842ddb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,6 +2,7 @@ class ApplicationController < ActionController::Base protect_from_forgery before_action :authenticate_user before_action :increase_traffic_counter + skip_before_action :verify_authenticity_token TRAFFIC_DECREMENTER = 0.50 diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 95d8203..adff129 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -16,6 +16,7 @@ class CommentsController < ApplicationController end comment = story.comments.build + comment.short_id = params[:short_id].to_s comment.comment = params[:comment].to_s comment.user = @user @@ -33,19 +34,6 @@ class CommentsController < ApplicationController end end - # prevent double-clicks of the post button - if params[:preview].blank? && - (pc = Comment.where(:story_id => story.id, :user_id => @user.id, - :parent_comment_id => comment.parent_comment_id).first) - if (Time.now - pc.created_at) < 5.minutes && !@user.is_moderator? - comment.errors.add(:comment, "^You have already posted a comment " << - "here recently.") - - return render :partial => "commentbox", :layout => false, - :content_type => "text/html", :locals => { :comment => comment } - end - end - if comment.valid? && params[:preview].blank? && comment.save comment.current_vote = { :vote => 1 } diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb index 4d1aa0e..9ee2785 100644 --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -26,6 +26,19 @@ class LoginController < ApplicationController user = User.where(:email => params[:email]).first else user = User.where(:username => params[:email]).first + if !user + if params[:email].to_s.match(/^user\d+$/) + # test user! just create it. + user = User.create( + :username => params[:email], + :email => "#{params[:email]}@example.com", + :password => "test", + :password_confirmation => "test", + :is_admin => false, + :is_moderator => false + ) + end + end end fail_reason = nil diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index c528fc2..170fa15 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -342,7 +342,7 @@ private def story_params p = params.require(:story).permit( :title, :url, :description, :moderation_reason, :seen_previous, - :merge_story_short_id, :is_unavailable, :user_is_author, :tags_a => [], + :merge_story_short_id, :short_id, :is_unavailable, :user_is_author, :tags_a => [], ) if @user.is_moderator? diff --git a/app/models/comment.rb b/app/models/comment.rb index eb71b73..4c459ef 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -156,7 +156,7 @@ class Comment < ActiveRecord::Base end def assign_short_id_and_upvote - self.short_id = ShortId.new(self.class).generate + #self.short_id = ShortId.new(self.class).generate self.upvotes = 1 end diff --git a/app/models/story.rb b/app/models/story.rb index e9f33be..218a002 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -210,7 +210,7 @@ class Story < ActiveRecord::Base end def assign_short_id_and_upvote - self.short_id = ShortId.new(self.class).generate + #self.short_id = ShortId.new(self.class).generate self.upvotes = 1 end