Skip to content

Commit ae86432

Browse files
committed
Refactor Example App to use new configs
1 parent f7dae62 commit ae86432

File tree

4 files changed

+26
-30
lines changed

4 files changed

+26
-30
lines changed

example_app/config/config.exs

+6-26
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,15 @@ config :phoenix, :generators,
3030

3131
config :addict,
3232
secret_key: "2432622431322479506177654c79303442354a5a4b784f592e444f332e",
33-
extra_validation: &ExampleApp.User.validate/2, # define extra validation here
33+
extra_validation: {ExampleApp.User, :validate}, # define extra validation here
3434
user_schema: ExampleApp.User,
3535
repo: ExampleApp.Repo,
3636
from_email: "[email protected]", # CHANGE THIS
3737
mailgun_domain: "https://api.mailgun.net/v3/CHANGE-THIS",
3838
mailgun_key: "key-CHANGE-THIS",
3939
mail_service: :mailgun,
40-
post_register: fn(conn, status, model) ->
41-
IO.inspect status
42-
IO.inspect model
43-
conn
44-
end,
45-
post_login: fn(conn, status, model) ->
46-
IO.inspect status
47-
IO.inspect model
48-
conn
49-
end,
50-
post_logout: fn(conn, status, model) ->
51-
IO.inspect status
52-
IO.inspect model
53-
conn
54-
end,
55-
post_reset_password: fn(conn, status, model) ->
56-
IO.inspect status
57-
IO.inspect model
58-
conn
59-
end,
60-
post_recover_password: fn(conn, status, model) ->
61-
IO.inspect status
62-
IO.inspect model
63-
conn
64-
end
40+
post_register: {ExampleApp, :post_register_hook},
41+
post_login: {ExampleApp, :post_login_hook},
42+
post_logout: {ExampleApp, :post_logout_hook},
43+
post_reset_password: {ExampleApp, :post_reset_password_hook},
44+
post_recover_password: {ExampleApp, :post_recover_password_hook}

example_app/config/prod.exs

+9-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,12 @@ config :logger, level: :info
6262

6363
# Finally import the config/prod.secret.exs
6464
# which should be versioned separately.
65-
import_config "prod.secret.exs"
65+
# import_config "prod.secret.exs"
66+
67+
config :example_app, ExampleApp.Repo,
68+
adapter: Ecto.Adapters.Postgres,
69+
username: "postgres",
70+
password: "postgres",
71+
database: "example_app_dev",
72+
hostname: "localhost",
73+
pool_size: 10

example_app/mix.exs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule ExampleApp.Mixfile do
1919
def application do
2020
[mod: {ExampleApp, []},
2121
applications: [:phoenix, :phoenix_html, :cowboy, :logger, :gettext,
22-
:phoenix_ecto, :postgrex, :phoenix_pubsub]]
22+
:phoenix_ecto, :postgrex, :phoenix_pubsub, :addict]]
2323
end
2424

2525
# Specifies which paths to compile per environment.
@@ -38,6 +38,7 @@ defmodule ExampleApp.Mixfile do
3838
{:phoenix_live_reload, "~> 1.0", only: :dev},
3939
{:gettext, "~> 0.9"},
4040
{:cowboy, "~> 1.0"},
41+
{:exrm, "~> 1.0"},
4142
{:addict, path: "../"}]
4243
end
4344

example_app/mix.lock

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
%{"comeonin": {:hex, :comeonin, "2.1.1", "6187c3764e98c3a963650f64cef067e01daed2f2de4177f666f60b50c14e9981", [:mix, :make, :make], []},
1+
%{"bbmustache": {:hex, :bbmustache, "1.0.4", "7ba94f971c5afd7b6617918a4bb74705e36cab36eb84b19b6a1b7ee06427aa38", [:rebar], []},
2+
"cf": {:hex, :cf, "0.2.1", "69d0b1349fd4d7d4dc55b7f407d29d7a840bf9a1ef5af529f1ebe0ce153fc2ab", [:rebar3], []},
3+
"comeonin": {:hex, :comeonin, "2.1.1", "6187c3764e98c3a963650f64cef067e01daed2f2de4177f666f60b50c14e9981", [:mix, :make, :make], []},
24
"connection": {:hex, :connection, "1.0.3", "3145f7416be3df248a4935f24e3221dc467c1e3a158d62015b35bd54da365786", [:mix], []},
35
"cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:rebar, :make], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, optional: false]}]},
46
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], []},
57
"db_connection": {:hex, :db_connection, "1.0.0-rc.3", "d9ceb670fe300271140af46d357b669983cd16bc0d01206d7d3222dde56cf038", [:mix], [{:sbroker, "~> 1.0.0-beta.3", [hex: :sbroker, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: true]}, {:connection, "~> 1.0.2", [hex: :connection, optional: false]}]},
68
"decimal": {:hex, :decimal, "1.1.2", "79a769d4657b2d537b51ef3c02d29ab7141d2b486b516c109642d453ee08e00c", [:mix], []},
79
"ecto": {:hex, :ecto, "2.0.2", "b02331c1f20bbe944dbd33c8ecd8f1ccffecc02e344c4471a891baf3a25f5406", [:mix], [{:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: true]}, {:sbroker, "~> 1.0-beta", [hex: :sbroker, optional: true]}, {:mariaex, "~> 0.7.7", [hex: :mariaex, optional: true]}, {:postgrex, "~> 0.11.2", [hex: :postgrex, optional: true]}, {:db_connection, "~> 1.0-rc.2", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}]},
10+
"erlware_commons": {:hex, :erlware_commons, "0.21.0", "a04433071ad7d112edefc75ac77719dd3e6753e697ac09428fc83d7564b80b15", [:rebar3], [{:cf, "0.2.1", [hex: :cf, optional: false]}]},
11+
"exrm": {:hex, :exrm, "1.0.8", "5aa8990cdfe300282828b02cefdc339e235f7916388ce99f9a1f926a9271a45d", [:mix], [{:relx, "~> 3.5", [hex: :relx, optional: false]}]},
812
"fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], []},
13+
"getopt": {:hex, :getopt, "0.8.2", "b17556db683000ba50370b16c0619df1337e7af7ecbf7d64fbf8d1d6bce3109b", [:rebar], []},
914
"gettext": {:hex, :gettext, "0.10.0", "b6f9a72be494ad84ccbfaf7349150ef319b9a5a2b634e4d3ccf70bd59e1e4178", [:mix], []},
1015
"mailgun": {:hex, :mailgun, "0.1.2", "37c1306675cf27a66a13dea3c9d479da2a990f0aed296b5addbd0b07529b667d", [:mix], [{:poison, "~> 1.4", [hex: :poison, optional: false]}]},
1116
"phoenix": {:hex, :phoenix, "1.2.0", "1bdeb99c254f4c534cdf98fd201dede682297ccc62fcac5d57a2627c3b6681fb", [:mix], [{:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: false]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, optional: false]}, {:plug, "~> 1.1", [hex: :plug, optional: false]}, {:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}]},
@@ -17,4 +22,6 @@
1722
"poison": {:hex, :poison, "1.5.2", "560bdfb7449e3ddd23a096929fb9fc2122f709bcc758b2d5d5a5c7d0ea848910", [:mix], []},
1823
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []},
1924
"postgrex": {:hex, :postgrex, "0.11.2", "139755c1359d3c5c6d6e8b1ea72556d39e2746f61c6ddfb442813c91f53487e8", [:mix], [{:connection, "~> 1.0", [hex: :connection, optional: false]}, {:db_connection, "~> 1.0-rc", [hex: :db_connection, optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}]},
20-
"ranch": {:hex, :ranch, "1.2.1", "a6fb992c10f2187b46ffd17ce398ddf8a54f691b81768f9ef5f461ea7e28c762", [:make], []}}
25+
"providers": {:hex, :providers, "1.6.0", "db0e2f9043ae60c0155205fcd238d68516331d0e5146155e33d1e79dc452964a", [:rebar3], [{:getopt, "0.8.2", [hex: :getopt, optional: false]}]},
26+
"ranch": {:hex, :ranch, "1.2.1", "a6fb992c10f2187b46ffd17ce398ddf8a54f691b81768f9ef5f461ea7e28c762", [:make], []},
27+
"relx": {:hex, :relx, "3.20.0", "b515b8317d25b3a1508699294c3d1fa6dc0527851dffc87446661bce21a36710", [:rebar3], [{:providers, "1.6.0", [hex: :providers, optional: false]}, {:getopt, "0.8.2", [hex: :getopt, optional: false]}, {:erlware_commons, "0.21.0", [hex: :erlware_commons, optional: false]}, {:cf, "0.2.1", [hex: :cf, optional: false]}, {:bbmustache, "1.0.4", [hex: :bbmustache, optional: false]}]}}

0 commit comments

Comments
 (0)