set var for flash by gem config

parent e5684e9f
Pipeline #991 canceled with stages
in 0 seconds
...@@ -29,3 +29,7 @@ ...@@ -29,3 +29,7 @@
# Ignore master key for decrypting credentials and more. # Ignore master key for decrypting credentials and more.
/config/master.key /config/master.key
config/settings.local.yml
config/settings/*.local.yml
config/environments/*.local.yml
...@@ -32,6 +32,7 @@ gem 'whenever', require: false ...@@ -32,6 +32,7 @@ gem 'whenever', require: false
# Use ActiveStorage variant # Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8' # gem 'mini_magick', '~> 4.8'
gem 'rubocop', '~> 0.88.0', require: false gem 'rubocop', '~> 0.88.0', require: false
gem 'config'
# Use Capistrano for deployment # Use Capistrano for deployment
# gem 'capistrano-rails', group: :development # gem 'capistrano-rails', group: :development
gem 'kaminari' gem 'kaminari'
......
...@@ -83,10 +83,52 @@ GEM ...@@ -83,10 +83,52 @@ GEM
execjs execjs
coffee-script-source (1.12.2) coffee-script-source (1.12.2)
concurrent-ruby (1.1.6) concurrent-ruby (1.1.6)
config (2.2.1)
deep_merge (~> 1.2, >= 1.2.1)
dry-validation (~> 1.0, >= 1.0.0)
connection_pool (2.2.3) connection_pool (2.2.3)
crass (1.0.6) crass (1.0.6)
deep_merge (1.2.1)
domain_name (0.5.20190701) domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0) unf (>= 0.0.5, < 1.0.0)
dry-configurable (0.11.6)
concurrent-ruby (~> 1.0)
dry-core (~> 0.4, >= 0.4.7)
dry-equalizer (~> 0.2)
dry-container (0.7.2)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (0.4.9)
concurrent-ruby (~> 1.0)
dry-equalizer (0.3.0)
dry-inflector (0.2.0)
dry-initializer (3.0.3)
dry-logic (1.0.7)
concurrent-ruby (~> 1.0)
dry-core (~> 0.2)
dry-equalizer (~> 0.2)
dry-schema (1.5.3)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.8, >= 0.8.3)
dry-core (~> 0.4)
dry-equalizer (~> 0.2)
dry-initializer (~> 3.0)
dry-logic (~> 1.0)
dry-types (~> 1.4)
dry-types (1.4.0)
concurrent-ruby (~> 1.0)
dry-container (~> 0.3)
dry-core (~> 0.4, >= 0.4.4)
dry-equalizer (~> 0.3)
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 1.0, >= 1.0.2)
dry-validation (1.5.4)
concurrent-ruby (~> 1.0)
dry-container (~> 0.7, >= 0.7.1)
dry-core (~> 0.4)
dry-equalizer (~> 0.2)
dry-initializer (~> 3.0)
dry-schema (~> 1.5)
erubi (1.9.0) erubi (1.9.0)
execjs (2.7.0) execjs (2.7.0)
ffi (1.13.1) ffi (1.13.1)
...@@ -274,6 +316,7 @@ DEPENDENCIES ...@@ -274,6 +316,7 @@ DEPENDENCIES
carrierwave (= 2.1.0) carrierwave (= 2.1.0)
chromedriver-helper chromedriver-helper
coffee-rails (~> 4.2) coffee-rails (~> 4.2)
config
jbuilder (~> 2.5) jbuilder (~> 2.5)
kaminari kaminari
listen (>= 3.0.5, < 3.2) listen (>= 3.0.5, < 3.2)
......
...@@ -6,12 +6,12 @@ class ConfirmationsController < ApplicationController ...@@ -6,12 +6,12 @@ class ConfirmationsController < ApplicationController
def mail_register def mail_register
email = params[:confirmation][:email].downcase email = params[:confirmation][:email].downcase
if User.find_by(email: email) if User.find_by(email: email)
flash[:danger] = ENV['email_existed'] flash[:danger] = Settings.sign_up.email_existed
redirect_to register_step1_path redirect_to register_step1_path
end end
@user = Confirmation.find_or_initialize_by(email: email) @user = Confirmation.find_or_initialize_by(email: email)
unless @user.save unless @user.save
flash[:danger] = ENV['email_format_failed'] flash[:danger] = Settings.sign_up.email_format_failed
return redirect_to register_step1_path return redirect_to register_step1_path
end end
......
...@@ -6,13 +6,13 @@ class ResetPasswordsController < ApplicationController ...@@ -6,13 +6,13 @@ class ResetPasswordsController < ApplicationController
def sending_email def sending_email
@user = User.find_by(email: params[:reset_password][:email].downcase) @user = User.find_by(email: params[:reset_password][:email].downcase)
unless @user unless @user
flash[:danger] = ENV['sending_email_failed'] flash[:danger] = Settings.reset_password.sending_email_failed
redirect_to reset_password_step1_path redirect_to reset_password_step1_path
else else
forgot_token = Digest::SHA1.hexdigest(SecureRandom.urlsafe_base64) forgot_token = Digest::SHA1.hexdigest(SecureRandom.urlsafe_base64)
@user.update_attribute(:remember_token, forgot_token) @user.update_attribute(:remember_token, forgot_token)
ResetPasswordMailer.reset_password(@user).deliver_later ResetPasswordMailer.reset_password(@user).deliver_later
flash[:success] = ENV['sending_email_success'] flash[:success] = Settings.reset_password.sending_email_success
redirect_to reset_password_step1_path redirect_to reset_password_step1_path
end end
end end
...@@ -21,7 +21,7 @@ class ResetPasswordsController < ApplicationController ...@@ -21,7 +21,7 @@ class ResetPasswordsController < ApplicationController
@user = User.find_by(remember_token: params[:token]) @user = User.find_by(remember_token: params[:token])
return redirect_to reset_password_step1_path unless @user && params[:token] return redirect_to reset_password_step1_path unless @user && params[:token]
if @user.token_expired? if @user.token_expired?
flash[:danger] = ENV['expiration'] flash[:danger] = Settings.user.expiration
redirect_to register_step1_path redirect_to register_step1_path
end end
end end
...@@ -29,11 +29,11 @@ class ResetPasswordsController < ApplicationController ...@@ -29,11 +29,11 @@ class ResetPasswordsController < ApplicationController
def update def update
@user = User.find_by(email: params[:user][:email]) @user = User.find_by(email: params[:user][:email])
unless @user.update_attributes(forgot_pass_params) unless @user.update_attributes(forgot_pass_params)
flash[:danger] = ENV['update_reset_pass'] flash[:danger] = Settings.reset_password.update_reset_pass
redirect_to reset_password_final_path(token: @user.remember_token) redirect_to reset_password_final_path(token: @user.remember_token)
else else
sign_in @user sign_in @user
flash[:success] = ENV['update_success'] flash[:success] = Settings.general_notify.update_success
redirect_to my_page_path redirect_to my_page_path
end end
end end
......
...@@ -10,7 +10,7 @@ class SessionsController < ApplicationController ...@@ -10,7 +10,7 @@ class SessionsController < ApplicationController
sign_in user sign_in user
redirect_to my_page_path redirect_to my_page_path
else else
flash.now[:danger] = ENV['sign_in_failed'] flash.now[:danger] = Settings.sign_in.sign_in_failed
render 'new' render 'new'
end end
end end
......
...@@ -11,10 +11,10 @@ class UsersController < ApplicationController ...@@ -11,10 +11,10 @@ class UsersController < ApplicationController
if current_user.authenticate(params[:user][:password]) if current_user.authenticate(params[:user][:password])
return respond_to { |format| format.js } unless current_user.update_attributes(user_params) return respond_to { |format| format.js } unless current_user.update_attributes(user_params)
flash[:success] = ENV['update_success'] flash[:success] = Settings.general_notify.update_success
redirect_to my_page_path redirect_to my_page_path
else else
flash.now[:danger] = ENV['password_mismatch'] flash.now[:danger] = Settings.user.password_mismatch
end end
end end
...@@ -22,7 +22,7 @@ class UsersController < ApplicationController ...@@ -22,7 +22,7 @@ class UsersController < ApplicationController
@email = Confirmation.find_by(confirm_token: params[:code]) @email = Confirmation.find_by(confirm_token: params[:code])
return redirect_to register_step1_path unless @email return redirect_to register_step1_path unless @email
if @email.token_expired? if @email.token_expired?
flash[:danger] = ENV['expiration'] flash[:danger] = Settings.user.expiration
redirect_to register_step1_path redirect_to register_step1_path
else else
@user = User.new @user = User.new
...@@ -40,7 +40,7 @@ class UsersController < ApplicationController ...@@ -40,7 +40,7 @@ class UsersController < ApplicationController
def sign_in_validation def sign_in_validation
return if signed_in? return if signed_in?
flash[:warning] = ENV['warning_signin'] flash[:warning] = Settings.user.warning_signin
redirect_to login_path redirect_to login_path
end end
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<%= f.label :email %> <%= f.label :email %>
</div> </div>
<div class="col-8-sm"> <div class="col-8-sm">
<%= f.text_field :email, class: 'input-email' %> <strong><%= current_user.email %></strong>
</div> </div>
</div> </div>
<div class="name-field"> <div class="name-field">
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<%= f.label :name, 'Full Name' %> <%= f.label :name, 'Full Name' %>
</div> </div>
<div class="col-8-sm"> <div class="col-8-sm">
<%= f.text_field :name, class: 'input-name' %> <strong><%= current_user.name %></strong>
</div> </div>
</div> </div>
<div class="cv-field"> <div class="cv-field">
......
...@@ -15,11 +15,6 @@ module Venjob ...@@ -15,11 +15,6 @@ module Venjob
YAML.load(File.open(env_file)).each do |key, value| YAML.load(File.open(env_file)).each do |key, value|
ENV[key.to_s] = value ENV[key.to_s] = value
end if File.exists?(env_file) end if File.exists?(env_file)
text_file = File.join(Rails.root, 'config', 'text_flash.yml')
YAML.load(File.open(text_file)).each do |key, value|
ENV[key.to_s] = value
end if File.exists?(text_file)
end end
# config.filter_parameter_logging << :oldpassword, :password # config.filter_parameter_logging << :oldpassword, :password
# Settings in config/environments/* take precedence over those specified here. # Settings in config/environments/* take precedence over those specified here.
......
# Settings.add_source!("#{Rails.root}/config/environments/development.yml")
# Settings.reload!
Config.setup do |config|
# Name of the constant exposing loaded settings
config.const_name = 'Settings'
# Ability to remove elements of the array set in earlier loaded settings file. For example value: '--'.
#
# config.knockout_prefix = nil
# Overwrite an existing value when merging a `nil` value.
# When set to `false`, the existing value is retained after merge.
#
# config.merge_nil_values = true
# Overwrite arrays found in previously loaded settings file. When set to `false`, arrays will be merged.
#
# config.overwrite_arrays = true
# Load environment variables from the `ENV` object and override any settings defined in files.
#
config.use_env = true
# Define ENV variable prefix deciding which variables to load into config.
#
# Reading variables from ENV is case-sensitive. If you define lowercase value below, ensure your ENV variables are
# prefixed in the same way.
#
# When not set it defaults to `config.const_name`.
#
config.env_prefix = 'SETTINGS'
# What string to use as level separator for settings loaded from ENV variables. Default value of '.' works well
# with Heroku, but you might want to change it for example for '__' to easy override settings from command line, where
# using dots in variable names might not be allowed (eg. Bash).
#
# config.env_separator = '.'
# Ability to process variables names:
# * nil - no change
# * :downcase - convert to lower case
#
# config.env_converter = :downcase
# Parse numeric values as integers instead of strings.
#
# config.env_parse_values = true
# Validate presence and type of specific config values. Check https://github.com/dry-rb/dry-validation for details.
#
# config.schema do
# required(:name).filled
# required(:age).maybe(:int?)
# required(:email).filled(format?: EMAIL_REGEX)
# end
end
#GENERAL general_notify:
update_success: 'Updated Successfully' update_success: 'Updated Successfully'
#TEXT OF USER user:
expiration: 'Link Confirmation is expiration too 24 hours to confirm. Please update your Email again!' expiration: 'Link Confirmation is expiration too 24 hours to confirm. Please update your Email again!'
password_mismatch: 'Password is mismatch' password_mismatch: 'Password is mismatch'
warning_signin: 'Please Sign In...' warning_signin: 'Please Sign In...'
#TEXT OF RESET PASSWORD reset_password:
sending_email_failed: 'Your Email invalid or not register' sending_email_failed: 'Your Email invalid or not register'
sending_email_success: 'Please check your email to change your password' sending_email_success: 'Please check your email to change your password'
update_reset_pass: 'Password or Password Confirmation is mismatch' update_reset_pass: 'Password or Password Confirmation is mismatch'
#TEXT OF SIGN IN sign_in:
sign_in_failed: 'Invalid email or password' sign_in_failed: 'Invalid email or password'
#TEXT OF SIGN UP sign_up:
email_existed: 'Email existed. Please change !!!' email_existed: 'Email existed. Please change !!!'
email_format_failed: 'Email formated invalid' email_format_failed: 'Email formated invalid'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment