Skip to content

Commit

Permalink
Merge pull request #108 from WPMedia/release_candidate/1.0.1/0
Browse files Browse the repository at this point in the history
* correcting compiling config to be false

* reorganizing assets.rb

* log for page created

* logging page deleted

* logging user created

* logging user deleted

* cleaning up timestamps and capitalization

* more loggin cleanup

* using time in user's timezone

* trying to get logs in ecs by uncommenting related lines in production.rb (#105)

* NAPPS-2239: trying stdout to get logs working (#106)

* trying to get logs in ecs by uncommenting related lines in production.rb

* trying shifting logger to stdout

* NAPPS-2239: adding comment to the fix that worked for deployed logs (#107)

* trying to get logs in ecs by uncommenting related lines in production.rb

* trying shifting logger to stdout

* adding a comment for posterity

* changing URL used in emails back to .pub address (#104)
  • Loading branch information
Kat-Alo authored Aug 29, 2023
2 parents 3ca7eef + b08c59c commit 258fc98
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 13 deletions.
5 changes: 5 additions & 0 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def create

if @page.save
redirect_to pages_url, notice: 'Page was successfully created.'
Rails.logger.info "#{@page.created_at} user, email #{current_user.email} and ID #{current_user.id}, created a page \"#{@page.name}\" with ID #{@page.id}."
else
render :new
end
Expand All @@ -59,6 +60,8 @@ def create
# PATCH/PUT /pages/1
def update
if @page.update(page_params)
now = Time.zone.now
Rails.logger.info "#{now} user with email #{current_user.email} and ID #{current_user.id} has updated a page called \"#{@page.name}\" with ID #{@page.id}."
redirect_to pages_url, notice: 'Page was successfully updated.'
else
render :edit
Expand All @@ -67,6 +70,8 @@ def update

# DELETE /pages/1
def destroy
now = Time.zone.now
Rails.logger.info "#{now} user, email #{current_user.email} and ID #{current_user.id}, deleted a page called \"#{@page.name}\" with ID #{@page.id}."
@page.destroy
redirect_to pages_url, notice: 'Page was successfully destroyed.'
end
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def create
redirect_to unknown_user_path and return false
end

now = Time.zone.now
Rails.logger.info "#{now} login email requested for #{params[:session][:email].downcase}"
UserMailer.login_email(user: user).deliver_later
# Allow the login page to display in the bookmarklet iframe
response.headers.delete "X-Frame-Options"
Expand All @@ -21,6 +23,8 @@ def token
if user[:expired]
redirect_to expired_token_path(user[:user].id)
else
now = Time.zone.now
Rails.logger.info "#{now} user with email #{user.email} and ID #{user.id} has successfully authenticated."
cookies.signed[:user_id] = { value: user.id, expires: 7.days.from_now, httponly: true, same_site: :none, secure: true }
redirect_to root_path
end
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def create
if @user.save
UserMailer.welcome_email(user: @user, invited_by: current_user).deliver_later

Rails.logger.info "#{@user.created_at} user, email #{current_user.email} and ID #{current_user.id}, created another user with email #{@user.email} with ID #{@user.id}."
redirect_to users_url, notice: 'User was successfully created.'
else
render :new
Expand All @@ -44,6 +45,8 @@ def update
end

if @user.update(user_params)
now = Time.zone.now
Rails.logger.info "#{now} user with email #{current_user.email} and ID #{current_user.id} has updated a user with email #{@user.email} with ID #{@user.id}."
redirect_to users_url, notice: 'User was successfully updated.'
else
render :edit
Expand All @@ -57,6 +60,8 @@ def destroy
return false
end

now = Time.zone.now
Rails.logger.info "#{now} user, email #{current_user.email} and ID #{current_user.id}, deleted a user with email #{@user.email} and ID #{@user.id}."
@user.subscriptions.destroy_all
@user.destroy
redirect_to users_url, notice: 'User was successfully deleted.'
Expand Down
4 changes: 2 additions & 2 deletions cfn/configs/klaxon-scheduled-task/dev/us-east-1/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ context:
APP_HOST: klaxon-dev.news-engineering.aws.wapo.pub.
RACK_ENV: production
RAILS_ENV: production
HOST_URL: "sandbox.washpost.arcpublishing.com"
HOST_URL: "klaxon-dev.news-engineering.aws.wapo.pub"
SECRET_KEY_BASE: "{{resolve:secretsmanager:/klaxon/prod/secret-key:SecretString:secret_key_base}}"
KLAXON_COMPILE_ASSETS: true
KLAXON_COMPILE_ASSETS: false
SMTP_PROVIDER: SES
SES_ADDRESS: "{{resolve:secretsmanager:/klaxon/ses-prod/smtp-user-credentials:SecretString:address}}"
SES_DOMAIN: "{{resolve:secretsmanager:/klaxon/ses-prod/smtp-user-credentials:SecretString:domain}}"
Expand Down
4 changes: 2 additions & 2 deletions cfn/configs/klaxon-scheduled-task/prod/us-east-1/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ context:
APP_HOST: klaxon-prod.news-engineering.aws.wapo.pub.
RACK_ENV: production
RAILS_ENV: production
HOST_URL: "washpost.arcpublishing.com"
HOST_URL: "klaxon-prod.news-engineering.aws.wapo.pub"
SECRET_KEY_BASE: "{{resolve:secretsmanager:/klaxon/prod/secret-key:SecretString:secret_key_base}}"
KLAXON_COMPILE_ASSETS: true
KLAXON_COMPILE_ASSETS: false
SMTP_PROVIDER: SES
SES_ADDRESS: "{{resolve:secretsmanager:/klaxon/ses-prod/smtp-user-credentials:SecretString:address}}"
SES_DOMAIN: "{{resolve:secretsmanager:/klaxon/ses-prod/smtp-user-credentials:SecretString:domain}}"
Expand Down
4 changes: 2 additions & 2 deletions cfn/configs/klaxon/dev/us-east-1/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,9 @@ context:
APP_HOST: klaxon-dev.news-engineering.aws.wapo.pub.
RACK_ENV: production
RAILS_ENV: production
HOST_URL: "sandbox.washpost.arcpublishing.com"
HOST_URL: "klaxon-dev.news-engineering.aws.wapo.pub"
SECRET_KEY_BASE: "{{resolve:secretsmanager:/klaxon/prod/secret-key:SecretString:secret_key_base}}"
KLAXON_COMPILE_ASSETS: true
KLAXON_COMPILE_ASSETS: false
SMTP_PROVIDER: SES
SES_ADDRESS: "{{resolve:secretsmanager:/klaxon/ses-prod/smtp-user-credentials:SecretString:address}}"
SES_DOMAIN: "{{resolve:secretsmanager:/klaxon/ses-prod/smtp-user-credentials:SecretString:domain}}"
Expand Down
4 changes: 2 additions & 2 deletions cfn/configs/klaxon/prod/us-east-1/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ context:
APP_HOST: klaxon-prod.news-engineering.aws.wapo.pub.
RACK_ENV: production
RAILS_ENV: production
HOST_URL: "washpost.arcpublishing.com"
HOST_URL: "klaxon-prod.news-engineering.aws.wapo.pub"
SECRET_KEY_BASE: "{{resolve:secretsmanager:/klaxon/prod/secret-key:SecretString:secret_key_base}}"
KLAXON_COMPILE_ASSETS: true
KLAXON_COMPILE_ASSETS: false
SMTP_PROVIDER: SES
SES_ADDRESS: "{{resolve:secretsmanager:/klaxon/ses-prod/smtp-user-credentials:SecretString:address}}"
SES_DOMAIN: "{{resolve:secretsmanager:/klaxon/ses-prod/smtp-user-credentials:SecretString:domain}}"
Expand Down
3 changes: 3 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

# Logs work locally but won't appear in the ECS console or CloudWatch without this:
config.logger = Logger.new(STDOUT)

# Use a different cache store in production.
# config.cache_store = :mem_cache_store

Expand Down
10 changes: 5 additions & 5 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Be sure to restart your server when you modify this file.

# Precompiles SVG so that org logo will display in deployed app
Rails.application.config.assets.precompile += %w( '.svg' )
Rails.application.config.assets.css_compressor = :sass

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

Expand All @@ -12,4 +8,8 @@

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w( search.js )
# addition of '.svg' allows custom logo to display
Rails.application.config.assets.precompile += %w( search.js '.svg')

# css_compressor needed for svg to display according to: https://stackoverflow.com/a/36992492
Rails.application.config.assets.css_compressor = :sass

0 comments on commit 258fc98

Please sign in to comment.