diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 536735c..18dfedd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,7 +7,7 @@ def register end def create - if User::User.find_by(email: params[:email]) != nil + if !User::User.find_by(email: params[:email]) if User::User.find_by(email: params[:email]).verified == false user = User::User.find_by(email: params[:email]) session[:current_user_id] = user.id @@ -46,7 +46,7 @@ def verify_email if u.use_otp(params[:code]) == true session[:email_verified] = true if params[:skip_passkey] == "true" - u.update(verified: true) + u.update!(verified: true) session[:authenticated] = true redirect_to controller: "domains", action: "index" else @@ -73,7 +73,7 @@ def update @user.verified = false end - @user.save + @user.save! redirect_to(controller: "users", action: "settings") end diff --git a/app/models/user/user.rb b/app/models/user/user.rb index df59472..91baafa 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -16,11 +16,11 @@ def mint_otp end def use_otp(token) - if begin + if !begin @hotp.verify(token.to_s, self.otp_counter.to_i) rescue nil - end != nil && + end.nil? && Time.now.to_i <= otp_last_minted + 600 self.otp_last_minted = nil diff --git a/config/environments/production.rb b/config/environments/production.rb index 31c6c7c..c3294ba 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -52,7 +52,7 @@ config.force_ssl = true # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new("#{Rails.root.join("log/production.log")}") + config.logger = ActiveSupport::Logger.new(Rails.root.join("log/production.log")) .tap { |logger| logger.formatter = ::Logger::Formatter.new } .then { |logger| ActiveSupport::TaggedLogging.new(logger) }