Hash passwords as soon as a new user is created

This commit is contained in:
Tom Hughes 2023-11-16 00:54:56 +00:00
parent b1553135fc
commit aaed886890
3 changed files with 4 additions and 3 deletions

View file

@ -61,7 +61,7 @@ Metrics/BlockNesting:
# Offense count: 26 # Offense count: 26
# Configuration parameters: CountComments, CountAsOne. # Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength: Metrics/ClassLength:
Max: 285 Max: 286
# Offense count: 59 # Offense count: 59
# Configuration parameters: AllowedMethods, AllowedPatterns. # Configuration parameters: AllowedMethods, AllowedPatterns.

View file

@ -104,11 +104,11 @@ class UsersController < ApplicationController
render :action => "new" render :action => "new"
elsif current_user.auth_provider.present? elsif current_user.auth_provider.present?
# Verify external authenticator before moving on # Verify external authenticator before moving on
session[:new_user] = current_user.attributes.slice("email", "display_name", "pass_crypt", "pass_crypt_confirmation") session[:new_user] = current_user.attributes.slice("email", "display_name", "pass_crypt")
redirect_to auth_url(current_user.auth_provider, current_user.auth_uid), :status => :temporary_redirect redirect_to auth_url(current_user.auth_provider, current_user.auth_uid), :status => :temporary_redirect
else else
# Save the user record # Save the user record
session[:new_user] = current_user.attributes.slice("email", "display_name", "pass_crypt", "pass_crypt_confirmation") session[:new_user] = current_user.attributes.slice("email", "display_name", "pass_crypt")
redirect_to :action => :terms redirect_to :action => :terms
end end
end end

View file

@ -115,6 +115,7 @@ class User < ApplicationRecord
alias_attribute :created_at, :creation_time alias_attribute :created_at, :creation_time
after_initialize :encrypt_password
before_save :encrypt_password before_save :encrypt_password
before_save :update_tile before_save :update_tile
after_save :spam_check after_save :spam_check