Skip to content

Commit 4ccd6b1

Browse files
authoredFeb 28, 2025··
Email-confirmation (#35)
* Let new users confirm their email for registration * Remove subtitle in permit statement
1 parent 3e5b403 commit 4ccd6b1

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed
 

‎app/controllers/admins_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def add_invites
4040

4141
def weekly_user_stats
4242
@created_users_by_week = Hash.new{ |h,k| h[k] = [] }
43-
@created_users = User.where("username IS NOT NULL and created_at IS NOT NULL")
43+
@created_users = User.where("username IS NOT NULL and created_at IS NOT NULL and confirmed_at IS NOT NULL")
4444
@created_users.find_each do |u|
4545
week = u.created_at.beginning_of_week.strftime("%Y-%m-%d")
4646
@created_users_by_week[week] << {username: u.username, closed_account: u.person.closed_account}

‎app/controllers/registrations_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def user_params
5252
params.require(:user).permit(
5353
:username, :email, :getting_started, :password, :password_confirmation, :language, :disable_mail,
5454
:show_community_spotlight_in_stream, :auto_follow_back, :auto_follow_back_aspect_id,
55-
:remember_me, :subtitle
55+
:remember_me
5656
)
5757
end
5858
end

‎app/models/comment.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ def save_parent_comment_guid
102102

103103
def min_time_delay
104104
return unless author.local?
105+
last_comment = last_created_comment
106+
return unless last_comment
105107

106-
return if last_created_comment.created_at < 1.minute.ago
108+
return if last_comment.created_at < 1.minute.ago
107109

108110
logger.info "Comment created too quickly"
109111
errors.add(:base, "Comments can only be created once per minute")

‎app/models/user.rb

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class User < ApplicationRecord
2828
devise :registerable,
2929
:recoverable, :rememberable, :trackable, :validatable,
3030
:lockable, :lastseenable, lock_strategy: :none, unlock_strategy: :none
31+
devise :confirmable
3132

3233
before_validation :strip_and_downcase_username
3334
before_validation :set_current_language, on: :create
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
class AddConfirmableToDevise < ActiveRecord::Migration[6.1]
4+
# rubocop:disable Rails/*
5+
def change
6+
add_column :users, :confirmation_token, :string
7+
add_column :users, :confirmed_at, :datetime
8+
add_column :users, :confirmation_sent_at, :datetime
9+
add_index :users, :confirmation_token, unique: true
10+
11+
User.update_all(confirmed_at: Time.current)
12+
end
13+
# rubocop:enable Rails/*
14+
end

0 commit comments

Comments
 (0)
Please sign in to comment.