@@ -5,27 +5,27 @@ defmodule PhoenixOauth2Provider.ApplicationController do
55 alias ExOauth2Provider.Applications
66 alias Plug.Conn
77
8- @ spec index ( Conn . t ( ) , map ( ) , map ( ) ) :: Conn . t ( )
9- def index ( conn , _params , resource_owner ) do
10- applications = Applications . get_applications_for ( resource_owner )
8+ @ spec index ( Conn . t ( ) , map ( ) , map ( ) , keyword ( ) ) :: Conn . t ( )
9+ def index ( conn , _params , resource_owner , config ) do
10+ applications = Applications . get_applications_for ( resource_owner , config )
1111
1212 render ( conn , "index.html" , applications: applications )
1313 end
1414
15- @ spec new ( Conn . t ( ) , map ( ) , map ( ) ) :: Conn . t ( )
16- def new ( conn , _params , _resource_owner ) do
15+ @ spec new ( Conn . t ( ) , map ( ) , map ( ) , keyword ( ) ) :: Conn . t ( )
16+ def new ( conn , _params , _resource_owner , config ) do
1717 changeset =
18- ExOauth2Provider.Config . application ( [ ] )
18+ ExOauth2Provider.Config . application ( config )
1919 |> struct ( )
20- |> Applications . change_application ( )
20+ |> Applications . change_application ( % { } , config )
2121
2222 render ( conn , "new.html" , changeset: changeset )
2323 end
2424
25- @ spec create ( Conn . t ( ) , map ( ) , map ( ) ) :: Conn . t ( )
26- def create ( conn , % { "oauth_application" => application_params } , resource_owner ) do
25+ @ spec create ( Conn . t ( ) , map ( ) , map ( ) , keyword ( ) ) :: Conn . t ( )
26+ def create ( conn , % { "oauth_application" => application_params } , resource_owner , config ) do
2727 resource_owner
28- |> Applications . create_application ( application_params )
28+ |> Applications . create_application ( application_params , config )
2929 |> case do
3030 { :ok , application } ->
3131 conn
@@ -37,26 +37,26 @@ defmodule PhoenixOauth2Provider.ApplicationController do
3737 end
3838 end
3939
40- @ spec show ( Conn . t ( ) , map ( ) , map ( ) ) :: Conn . t ( )
41- def show ( conn , % { "uid" => uid } , resource_owner ) do
42- application = get_application_for! ( resource_owner , uid )
40+ @ spec show ( Conn . t ( ) , map ( ) , map ( ) , keyword ( ) ) :: Conn . t ( )
41+ def show ( conn , % { "uid" => uid } , resource_owner , config ) do
42+ application = get_application_for! ( resource_owner , uid , config )
4343
4444 render ( conn , "show.html" , application: application )
4545 end
4646
47- @ spec edit ( Conn . t ( ) , map ( ) , map ( ) ) :: Conn . t ( )
48- def edit ( conn , % { "uid" => uid } , resource_owner ) do
49- application = get_application_for! ( resource_owner , uid )
50- changeset = Applications . change_application ( application )
47+ @ spec edit ( Conn . t ( ) , map ( ) , map ( ) , keyword ( ) ) :: Conn . t ( )
48+ def edit ( conn , % { "uid" => uid } , resource_owner , config ) do
49+ application = get_application_for! ( resource_owner , uid , config )
50+ changeset = Applications . change_application ( application , % { } , config )
5151
5252 render ( conn , "edit.html" , application: application , changeset: changeset )
5353 end
5454
55- @ spec update ( Conn . t ( ) , map ( ) , map ( ) ) :: Conn . t ( )
56- def update ( conn , % { "uid" => uid , "oauth_application" => application_params } , resource_owner ) do
57- application = get_application_for! ( resource_owner , uid )
55+ @ spec update ( Conn . t ( ) , map ( ) , map ( ) , keyword ( ) ) :: Conn . t ( )
56+ def update ( conn , % { "uid" => uid , "oauth_application" => application_params } , resource_owner , config ) do
57+ application = get_application_for! ( resource_owner , uid , config )
5858
59- case Applications . update_application ( application , application_params ) do
59+ case Applications . update_application ( application , application_params , config ) do
6060 { :ok , application } ->
6161 conn
6262 |> put_flash ( :info , "Application updated successfully." )
@@ -67,19 +67,19 @@ defmodule PhoenixOauth2Provider.ApplicationController do
6767 end
6868 end
6969
70- @ spec delete ( Conn . t ( ) , map ( ) , map ( ) ) :: Conn . t ( )
71- def delete ( conn , % { "uid" => uid } , resource_owner ) do
70+ @ spec delete ( Conn . t ( ) , map ( ) , map ( ) , keyword ( ) ) :: Conn . t ( )
71+ def delete ( conn , % { "uid" => uid } , resource_owner , config ) do
7272 { :ok , _application } =
7373 resource_owner
74- |> get_application_for! ( uid )
75- |> Applications . delete_application ( )
74+ |> get_application_for! ( uid , config )
75+ |> Applications . delete_application ( config )
7676
7777 conn
7878 |> put_flash ( :info , "Application deleted successfully." )
7979 |> redirect ( to: Routes . oauth_application_path ( conn , :index ) )
8080 end
8181
82- defp get_application_for! ( resource_owner , uid ) do
83- Applications . get_application_for! ( resource_owner , uid )
82+ defp get_application_for! ( resource_owner , uid , config ) do
83+ Applications . get_application_for! ( resource_owner , uid , config )
8484 end
8585end
0 commit comments