Skip to content

Commit 2bf0157

Browse files
committed
Fix show new session screen for newly generated project. closes #390
- Remove logged_out_url from default config - Some template reformatting to aligh with the code formatter
1 parent 72b6688 commit 2bf0157

21 files changed

+228
-166
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ See these [0.5.x to 0.6.x upgrade instructions](https://gist.github.com/smpallen
1414
* Updated to Comeonin 4.0
1515
* Add support for configurable password hashing algorithms
1616
* Speed up tests by configuring the Bcrypt algorithm
17+
* Format may generator templates to align with code formatter
1718

1819
* Bug Fixes
1920
* Fixed detection of remember me checkbox on session new page
2021
* Fixed compiled gettext in view helpers
22+
* Fix new session screen issue on newly generated project #390
2123

2224
* Deprecations
2325
* Removed the coherence.make_templates task since its no longer needed with the new controller design

lib/mix/tasks/coh.gen.controllers.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ defmodule Mix.Tasks.Coh.Gen.Controllers do
9393
9494
# Change this block
9595
scope "/"#{web_base} do
96-
pipe_through :browser
96+
pipe_through(:browser)
9797
coherence_routes()
9898
end
9999
100100
# Change this block
101101
scope "/"#{web_base} do
102-
pipe_through :protected
103-
coherence_routes :protected
102+
pipe_through(:protected)
103+
coherence_routes(:protected)
104104
end
105105
106106
# ...

lib/mix/tasks/coh.install.ex

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ defmodule Mix.Tasks.Coh.Install do
288288
router: #{config[:router]},
289289
password_hashing_alg: #{config[:password_hashing_alg]},
290290
messages_backend: #{config[:web_base]}.Coherence.Messages,#{layout_field(config)}
291-
logged_out_url: "/",#{user_active_field(config)}
292291
registration_permitted_attributes: ["email","name","password","current_password","password_confirmation"],
293292
invitation_permitted_attributes: ["name","email"],
294293
password_reset_permitted_attributes: ["reset_password_token","password","password_confirmation"],
@@ -308,11 +307,11 @@ defmodule Mix.Tasks.Coh.Install do
308307
defp layout_field(_),
309308
do: ""
310309

311-
defp user_active_field(%{user_active_field?: true}),
312-
do: "\n user_active_field: true,"
310+
# defp user_active_field(%{user_active_field?: true}),
311+
# do: "\n user_active_field: true,"
313312

314-
defp user_active_field(_),
315-
do: ""
313+
# defp user_active_field(_),
314+
# do: ""
316315

317316
defp swoosh_config(string, %{web_base: web_base, use_email?: true}) do
318317
string <>
@@ -346,7 +345,8 @@ defmodule Mix.Tasks.Coh.Install do
346345
end
347346

348347
if confirmed do
349-
File.write!(@config_file, source <> "\n" <> string)
348+
# File.write!(@config_file, source <> "\n" <> string)
349+
File.write!(@config_file, Code.format_string!(source <> "\n" <> string))
350350
shell_info(config, "Your config/config.exs file was updated.")
351351
false
352352
else
@@ -1053,43 +1053,43 @@ defmodule Mix.Tasks.Coh.Install do
10531053
use Coherence.Router # Add this
10541054
10551055
pipeline :browser do
1056-
plug :accepts, ["html"]
1057-
plug :fetch_session
1058-
plug :fetch_flash
1059-
plug :protect_from_forgery
1060-
plug :put_secure_browser_headers
1061-
plug Coherence.Authentication.Session # Add this
1056+
plug(:accepts, ["html"])
1057+
plug(:fetch_session)
1058+
plug(:fetch_flash)
1059+
plug(:protect_from_forgery)
1060+
plug(:put_secure_browser_headers)
1061+
plug(Coherence.Authentication.Session) # Add this
10621062
end
10631063
10641064
pipeline :protected do
1065-
plug :accepts, ["html"]
1066-
plug :fetch_session
1067-
plug :fetch_flash
1068-
plug :protect_from_forgery
1069-
plug :put_secure_browser_headers
1070-
plug Coherence.Authentication.Session, protected: true # Add this
1065+
plug(:accepts, ["html"])
1066+
plug(:fetch_session)
1067+
plug(:fetch_flash)
1068+
plug(:protect_from_forgery)
1069+
plug(:put_secure_browser_headers)
1070+
plug(Coherence.Authentication.Session, protected: true) # Add this
10711071
end
10721072
10731073
# Add this block
10741074
scope "/" do
1075-
pipe_through :browser
1075+
pipe_through(:browser)
10761076
coherence_routes()
10771077
end
10781078
10791079
# Add this block
10801080
scope "/" do
1081-
pipe_through :protected
1082-
coherence_routes :protected
1081+
pipe_through(:protected)
1082+
coherence_routes(:protected)
10831083
end
10841084
10851085
scope "/", #{web_base} do
1086-
pipe_through :browser
1087-
get "/", PageController, :index
1086+
pipe_through(:browser)
1087+
get("/", PageController, :index)
10881088
# Add public routes below
10891089
end
10901090
10911091
scope "/", #{web_base} do
1092-
pipe_through :protected
1092+
pipe_through(:protected)
10931093
# Add protected routes below
10941094
end
10951095
end
@@ -1170,8 +1170,6 @@ defmodule Mix.Tasks.Coh.Install do
11701170
|> Atom.to_string()
11711171
|> Mix.Phoenix.inflect()
11721172

1173-
# IO.puts "binding: #{inspect binding}"
1174-
11751173
base = opts[:module] || binding[:base]
11761174
web_base = opts[:web_module] || base <> "Web"
11771175
opts = Keyword.put(opts, :base, base)
@@ -1228,8 +1226,6 @@ defmodule Mix.Tasks.Coh.Install do
12281226
]
12291227
|> Enum.into(opts_map)
12301228
|> do_default_config(opts)
1231-
1232-
# |> IO.inspect(label: "config")
12331229
end
12341230

12351231
defp do_bin_opts(bin_opts) do

priv/templates/coh.gen.controllers/controllers/coherence/confirmation_controller.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule <%= web_base %>.Coherence.ConfirmationController do
88
use CoherenceWeb, :controller
99
use Coherence.ConfirmationControllerBase, schemas: <%= base %>.Coherence.Schemas
1010

11-
plug Coherence.ValidateOption, :confirmable
12-
plug :layout_view, view: Coherence.ConfirmationView, caller: __MODULE__
13-
plug :redirect_logged_in when action in [:new]
11+
plug(Coherence.ValidateOption, :confirmable)
12+
plug(:layout_view, view: Coherence.ConfirmationView, caller: __MODULE__)
13+
plug(:redirect_logged_in when action in [:new])
1414
end

priv/templates/coh.gen.controllers/controllers/coherence/invitation_controller.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule <%= web_base %>.Coherence.InvitationController do
1313
use CoherenceWeb, :controller
1414
use Coherence.InvitationControllerBase, schemas: <%= base %>.Coherence.Schemas
1515

16-
plug Coherence.ValidateOption, :invitable
17-
plug :scrub_params, "user" when action in [:create_user]
18-
plug :layout_view, view: Coherence.InvitationView, caller: __MODULE__
16+
plug(Coherence.ValidateOption, :invitable)
17+
plug(:scrub_params, "user" when action in [:create_user])
18+
plug(:layout_view, view: Coherence.InvitationView, caller: __MODULE__)
1919
end

priv/templates/coh.gen.controllers/controllers/coherence/password_controller.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ defmodule <%= web_base %>.Coherence.PasswordController do
1414
use CoherenceWeb, :controller
1515
use Coherence.PasswordControllerBase, schemas: <%= base %>.Coherence.Schemas
1616

17-
plug :layout_view, view: Coherence.PasswordView, caller: __MODULE__
18-
plug :redirect_logged_in when action in [:new, :create, :edit, :update]
17+
plug(:layout_view, view: Coherence.PasswordView, caller: __MODULE__)
18+
plug(:redirect_logged_in when action in [:new, :create, :edit, :update])
1919
end

priv/templates/coh.gen.controllers/controllers/coherence/registration_controller.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ defmodule <%= web_base %>.Coherence.RegistrationController do
1313
use CoherenceWeb, :controller
1414
use Coherence.RegistrationControllerBase, schemas: <%= base %>.Coherence.Schemas
1515

16-
plug Coherence.RequireLogin when action in ~w(show edit update delete)a
17-
plug Coherence.ValidateOption, :registerable
18-
plug :scrub_params, "registration" when action in [:create, :update]
16+
plug(Coherence.RequireLogin when action in ~w(show edit update delete)a)
17+
plug(Coherence.ValidateOption, :registerable)
18+
plug(:scrub_params, "registration" when action in [:create, :update])
1919

20-
plug :layout_view, view: Coherence.RegistrationView, caller: __MODULE__
21-
plug :redirect_logged_in when action in [:new, :create]
20+
plug(:layout_view, view: Coherence.RegistrationView, caller: __MODULE__)
21+
plug(:redirect_logged_in when action in [:new, :create])
2222
end

priv/templates/coh.gen.controllers/controllers/coherence/session_controller.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ defmodule <%= web_base %>.Coherence.SessionController do
99
use CoherenceWeb, :controller
1010
use Coherence.SessionControllerBase, schemas: <%= base %>.Coherence.Schemas
1111

12-
plug :layout_view, view: Coherence.SessionView, caller: __MODULE__
13-
plug :redirect_logged_in when action in [:new, :create]
12+
plug(:layout_view, view: Coherence.SessionView, caller: __MODULE__)
13+
plug(:redirect_logged_in when action in [:new, :create])
1414
end

priv/templates/coh.gen.controllers/controllers/coherence/unlock_controller.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule <%= web_base %>.Coherence.UnlockController do
1010
use CoherenceWeb, :controller
1111
use Coherence.UnlockControllerBase, schemas: <%= base %>.Coherence.Schemas
1212

13-
plug Coherence.ValidateOption, :unlockable_with_token
14-
plug :layout_view, view: Coherence.UnlockView, caller: __MODULE__
15-
plug :redirect_logged_in when action in [:new, :create, :edit]
13+
plug(Coherence.ValidateOption, :unlockable_with_token)
14+
plug(:layout_view, view: Coherence.UnlockView, caller: __MODULE__)
15+
plug(:redirect_logged_in when action in [:new, :create, :edit])
1616
end

priv/templates/coh.install/coherence_messages.ex

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,21 @@ defmodule <%= web_base %>.Coherence.Messages do
3232
def cant_find_that_token, do: dgettext(@domain, "Can't find that token")
3333
def confirmation_email_sent, do: dgettext(@domain, "Confirmation email sent.")
3434
def confirmation_token_expired, do: dgettext(@domain, "Confirmation token expired.")
35-
def could_not_find_that_email_address, do: dgettext(@domain, "Could not find that email address")
35+
36+
def could_not_find_that_email_address,
37+
do: dgettext(@domain, "Could not find that email address")
38+
3639
def forgot_your_password, do: dgettext(@domain, "Forgot your password?")
3740
def http_authentication_required, do: dgettext(@domain, "HTTP Authentication Required")
38-
def incorrect_login_or_password(opts), do: dgettext(@domain, "Incorrect %{login_field} or password.", opts)
41+
42+
def incorrect_login_or_password(opts),
43+
do: dgettext(@domain, "Incorrect %{login_field} or password.", opts)
44+
3945
def invalid_current_password, do: dgettext(@domain, "invalid current password")
40-
def invalid_invitation, do: dgettext(@domain, "Invalid Invitation. Please contact the site administrator.")
46+
47+
def invalid_invitation,
48+
do: dgettext(@domain, "Invalid Invitation. Please contact the site administrator.")
49+
4150
def invalid_request, do: dgettext(@domain, "Invalid Request.")
4251
def invalid_confirmation_token, do: dgettext(@domain, "Invalid confirmation token.")
4352
def invalid_email_or_password, do: dgettext(@domain, "Invalid email or password.")
@@ -47,33 +56,64 @@ defmodule <%= web_base %>.Coherence.Messages do
4756
def invitation_already_sent, do: dgettext(@domain, "Invitation already sent.")
4857
def invitation_sent, do: dgettext(@domain, "Invitation sent.")
4958
def invite_someone, do: dgettext(@domain, "Invite Someone")
50-
def maximum_login_attempts_exceeded, do: dgettext(@domain, "Maximum Login attempts exceeded. Your account has been locked.")
59+
60+
def maximum_login_attempts_exceeded,
61+
do: dgettext(@domain, "Maximum Login attempts exceeded. Your account has been locked.")
62+
5163
def need_an_account, do: dgettext(@domain, "Need An Account?")
5264
def not_locked, do: dgettext(@domain, "not locked")
5365
def password_reset_token_expired, do: dgettext(@domain, "Password reset token expired.")
5466
def password_updated_successfully, do: dgettext(@domain, "Password updated successfully.")
55-
def problem_confirming_user_account, do: dgettext(@domain, "Problem confirming user account. Please contact the system administrator.")
56-
def registration_created_successfully, do: dgettext(@domain, "Registration created successfully.")
67+
68+
def problem_confirming_user_account,
69+
do:
70+
dgettext(
71+
@domain,
72+
"Problem confirming user account. Please contact the system administrator."
73+
)
74+
75+
def registration_created_successfully,
76+
do: dgettext(@domain, "Registration created successfully.")
77+
5778
def required, do: dgettext(@domain, "required")
5879
def resend_confirmation_email, do: dgettext(@domain, "Resend confirmation email")
59-
def reset_email_sent, do: dgettext(@domain, "Reset email sent. Check your email for a reset link.")
80+
81+
def reset_email_sent,
82+
do: dgettext(@domain, "Reset email sent. Check your email for a reset link.")
83+
6084
def restricted_area, do: dgettext(@domain, "Restricted Area")
6185
def send_an_unlock_email, do: dgettext(@domain, "Send an unlock email")
6286
def sign_in, do: dgettext(@domain, "Sign In")
6387
def sign_out, do: dgettext(@domain, "Sign Out")
6488
def signed_in_successfully, do: dgettext(@domain, "Signed in successfully.")
65-
def too_many_failed_login_attempts, do: dgettext(@domain, "Too many failed login attempts. Account has been locked.")
89+
90+
def too_many_failed_login_attempts,
91+
do: dgettext(@domain, "Too many failed login attempts. Account has been locked.")
92+
6693
def unauthorized_ip_address, do: dgettext(@domain, "Unauthorized IP Address")
6794
def unlock_instructions_sent, do: dgettext(@domain, "Unlock Instructions sent.")
68-
def user_account_confirmed_successfully, do: dgettext(@domain, "User account confirmed successfully.")
95+
96+
def user_account_confirmed_successfully,
97+
do: dgettext(@domain, "User account confirmed successfully.")
98+
6999
def user_already_has_an_account, do: dgettext(@domain, "User already has an account!")
70-
def you_must_confirm_your_account, do: dgettext(@domain, "You must confirm your account before you can login.")
100+
101+
def you_must_confirm_your_account,
102+
do: dgettext(@domain, "You must confirm your account before you can login.")
103+
71104
def your_account_has_been_unlocked, do: dgettext(@domain, "Your account has been unlocked")
72105
def your_account_is_not_locked, do: dgettext(@domain, "Your account is not locked.")
106+
73107
def verify_user_token(opts),
74108
do: dgettext(@domain, "Invalid %{user_token} error: %{error}", opts)
109+
75110
def you_are_using_an_invalid_security_token,
76-
do: dgettext(@domain, "You are using an invalid security token for this site! This security\nviolation has been logged.\n")
111+
do:
112+
dgettext(
113+
@domain,
114+
"You are using an invalid security token for this site! This security\nviolation has been logged.\n"
115+
)
116+
77117
def mailer_required, do: dgettext(@domain, "Mailer configuration required!")
78118
def account_is_inactive(), do: dgettext(@domain, "Account is inactive!")
79119
end

0 commit comments

Comments
 (0)