From acbd46aca06ac16fbd1a4806ff9501a3309453b6 Mon Sep 17 00:00:00 2001 From: uu59 Date: Tue, 3 Jun 2014 14:53:27 +0900 Subject: [PATCH 1/2] Store default password in YAML --- config/application.yml | 1 + db/seeds.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/application.yml b/config/application.yml index 283516c..940f654 100644 --- a/config/application.yml +++ b/config/application.yml @@ -1,4 +1,5 @@ defaults: &defaults + default_password: changeme recommended_plugins: - category: filter name: "rewrite-tag-filter" diff --git a/db/seeds.rb b/db/seeds.rb index d0bf4c4..45bcc9c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,5 +7,5 @@ # Mayor.create(name: 'Emanuel', city: cities.first) unless User.exists? - User.create!(name: "admin", password: "changeme") + User.create!(name: "admin", password: Settings.default_password) end From 5836021b66feab1299490688a19e70ff8c666fc9 Mon Sep 17 00:00:00 2001 From: uu59 Date: Tue, 3 Jun 2014 14:54:12 +0900 Subject: [PATCH 2/2] Display warning message when sign in with default password. close #1 --- app/controllers/sessions_controller.rb | 3 +++ app/views/layouts/application.html.erb | 1 + app/views/shared/_flash.html.haml | 5 +++++ config/locales/translation_en.yml | 1 + config/locales/translation_ja.yml | 1 + 5 files changed, 11 insertions(+) create mode 100644 app/views/shared/_flash.html.haml diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 747e9d2..7181870 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -9,6 +9,9 @@ class SessionsController < ApplicationController return render :new end sign_in user + if session_params[:password] == Settings.default_password + flash[:warning] = t('terms.changeme_password') + end redirect_to root_path end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2e3392a..cab7d16 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -96,6 +96,7 @@
+ <%= render partial: "shared/flash" %> <% if content_for?(:page_head) %>
diff --git a/app/views/shared/_flash.html.haml b/app/views/shared/_flash.html.haml new file mode 100644 index 0000000..7974c60 --- /dev/null +++ b/app/views/shared/_flash.html.haml @@ -0,0 +1,5 @@ +.row + - if flash[:warning] + %p.alert.alert-warning + =raw flash[:warning] + diff --git a/config/locales/translation_en.yml b/config/locales/translation_en.yml index 189f4a6..2283a89 100644 --- a/config/locales/translation_en.yml +++ b/config/locales/translation_en.yml @@ -27,6 +27,7 @@ en: installing: "Installing: %{target}" uninstalling: "Uninstalling: %{target}" search: Search + changeme_password: 'Change the password from default for your security' destroy_confirm_title: "%{target} Deletion" destroy_confirm_body: | Really delete? diff --git a/config/locales/translation_ja.yml b/config/locales/translation_ja.yml index 841e677..0beae2f 100644 --- a/config/locales/translation_ja.yml +++ b/config/locales/translation_ja.yml @@ -27,6 +27,7 @@ ja: installing: "インストール中: %{target}" uninstalling: "アンインストール中: %{target}" search: 検索 + changeme_password: 'パスワードを初期設定から変更してください' destroy_confirm_title: "%{target}を削除" destroy_confirm_body: | 削除しますか?