set var for flash by gem config

parent e5684e9f
Pipeline #991 canceled with stages
in 0 seconds
......@@ -29,3 +29,7 @@
# Ignore master key for decrypting credentials and more.
/config/master.key
config/settings.local.yml
config/settings/*.local.yml
config/environments/*.local.yml
......@@ -32,6 +32,7 @@ gem 'whenever', require: false
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
gem 'rubocop', '~> 0.88.0', require: false
gem 'config'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'kaminari'
......
......@@ -83,10 +83,52 @@ GEM
execjs
coffee-script-source (1.12.2)
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)
crass (1.0.6)
deep_merge (1.2.1)
domain_name (0.5.20190701)
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)
execjs (2.7.0)
ffi (1.13.1)
......@@ -274,6 +316,7 @@ DEPENDENCIES
carrierwave (= 2.1.0)
chromedriver-helper
coffee-rails (~> 4.2)
config
jbuilder (~> 2.5)
kaminari
listen (>= 3.0.5, < 3.2)
......
......@@ -6,12 +6,12 @@ class ConfirmationsController < ApplicationController
def mail_register
email = params[:confirmation][:email].downcase
if User.find_by(email: email)
flash[:danger] = ENV['email_existed']
flash[:danger] = Settings.sign_up.email_existed
redirect_to register_step1_path
end
@user = Confirmation.find_or_initialize_by(email: email)
unless @user.save
flash[:danger] = ENV['email_format_failed']
flash[:danger] = Settings.sign_up.email_format_failed
return redirect_to register_step1_path
end
......
......@@ -6,13 +6,13 @@ class ResetPasswordsController < ApplicationController
def sending_email
@user = User.find_by(email: params[:reset_password][:email].downcase)
unless @user
flash[:danger] = ENV['sending_email_failed']
flash[:danger] = Settings.reset_password.sending_email_failed
redirect_to reset_password_step1_path
else
forgot_token = Digest::SHA1.hexdigest(SecureRandom.urlsafe_base64)
@user.update_attribute(:remember_token, forgot_token)
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
end
end
......@@ -21,7 +21,7 @@ class ResetPasswordsController < ApplicationController
@user = User.find_by(remember_token: params[:token])
return redirect_to reset_password_step1_path unless @user && params[:token]
if @user.token_expired?
flash[:danger] = ENV['expiration']
flash[:danger] = Settings.user.expiration
redirect_to register_step1_path
end
end
......@@ -29,11 +29,11 @@ class ResetPasswordsController < ApplicationController
def update
@user = User.find_by(email: params[:user][:email])
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)
else
sign_in @user
flash[:success] = ENV['update_success']
flash[:success] = Settings.general_notify.update_success
redirect_to my_page_path
end
end
......
......@@ -10,7 +10,7 @@ class SessionsController < ApplicationController
sign_in user
redirect_to my_page_path
else
flash.now[:danger] = ENV['sign_in_failed']
flash.now[:danger] = Settings.sign_in.sign_in_failed
render 'new'
end
end
......
......@@ -11,10 +11,10 @@ class UsersController < ApplicationController
if current_user.authenticate(params[:user][:password])
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
else
flash.now[:danger] = ENV['password_mismatch']
flash.now[:danger] = Settings.user.password_mismatch
end
end
......@@ -22,7 +22,7 @@ class UsersController < ApplicationController
@email = Confirmation.find_by(confirm_token: params[:code])
return redirect_to register_step1_path unless @email
if @email.token_expired?
flash[:danger] = ENV['expiration']
flash[:danger] = Settings.user.expiration
redirect_to register_step1_path
else
@user = User.new
......@@ -40,7 +40,7 @@ class UsersController < ApplicationController
def sign_in_validation
return if signed_in?
flash[:warning] = ENV['warning_signin']
flash[:warning] = Settings.user.warning_signin
redirect_to login_path
end
......
......@@ -9,7 +9,7 @@
<%= f.label :email %>
</div>
<div class="col-8-sm">
<%= f.text_field :email, class: 'input-email' %>
<strong><%= current_user.email %></strong>
</div>
</div>
<div class="name-field">
......@@ -17,7 +17,7 @@
<%= f.label :name, 'Full Name' %>
</div>
<div class="col-8-sm">
<%= f.text_field :name, class: 'input-name' %>
<strong><%= current_user.name %></strong>
</div>
</div>
<div class="cv-field">
......
......@@ -15,11 +15,6 @@ module Venjob
YAML.load(File.open(env_file)).each do |key, value|
ENV[key.to_s] = value
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
# config.filter_parameter_logging << :oldpassword, :password
# 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
update_success: 'Updated Successfully'
general_notify:
update_success: 'Updated Successfully'
#TEXT OF USER
expiration: 'Link Confirmation is expiration too 24 hours to confirm. Please update your Email again!'
password_mismatch: 'Password is mismatch'
warning_signin: 'Please Sign In...'
user:
expiration: 'Link Confirmation is expiration too 24 hours to confirm. Please update your Email again!'
password_mismatch: 'Password is mismatch'
warning_signin: 'Please Sign In...'
#TEXT OF RESET PASSWORD
sending_email_failed: 'Your Email invalid or not register'
sending_email_success: 'Please check your email to change your password'
update_reset_pass: 'Password or Password Confirmation is mismatch'
reset_password:
sending_email_failed: 'Your Email invalid or not register'
sending_email_success: 'Please check your email to change your password'
update_reset_pass: 'Password or Password Confirmation is mismatch'
#TEXT OF SIGN IN
sign_in_failed: 'Invalid email or password'
sign_in:
sign_in_failed: 'Invalid email or password'
#TEXT OF SIGN UP
email_existed: 'Email existed. Please change !!!'
email_format_failed: 'Email formated invalid'
sign_up:
email_existed: 'Email existed. Please change !!!'
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