@@ -3,37 +3,46 @@ defmodule PhoenixOauth2Provider.ApplicationController do
33 use PhoenixOauth2Provider.Web , :controller
44
55 alias ExOauth2Provider.OauthApplications
6- import PhoenixOauth2Provider
76
87 def index ( conn , _params ) do
9- applications = OauthApplications . get_applications_for ( current_resource_owner ( conn ) )
8+ applications = conn
9+ |> PhoenixOauth2Provider . current_resource_owner ( )
10+ |> OauthApplications . get_applications_for ( )
11+
1012 render ( conn , "index.html" , applications: applications )
1113 end
1214
1315 def new ( conn , _params ) do
1416 changeset = OauthApplications . change_application ( % OauthApplications.OauthApplication { } )
17+
1518 render ( conn , "new.html" , changeset: changeset )
1619 end
1720
1821 def create ( conn , % { "oauth_application" => application_params } ) do
19- case OauthApplications . create_application ( current_resource_owner ( conn ) , application_params ) do
22+ conn
23+ |> PhoenixOauth2Provider . current_resource_owner ( )
24+ |> OauthApplications . create_application ( application_params )
25+ |> case do
2026 { :ok , application } ->
2127 conn
2228 |> put_flash ( :info , "Application created successfully." )
23- |> redirect ( to: router_helpers ( ) . oauth_application_path ( conn , :show , application ) )
29+ |> redirect ( to: PhoenixOauth2Provider . router_helpers ( ) . oauth_application_path ( conn , :show , application ) )
30+
2431 { :error , % Ecto.Changeset { } = changeset } ->
2532 render ( conn , "new.html" , changeset: changeset )
2633 end
2734 end
2835
2936 def show ( conn , % { "uid" => uid } ) do
3037 application = get_application_for! ( conn , uid )
38+
3139 render ( conn , "show.html" , application: application )
3240 end
3341
3442 def edit ( conn , % { "uid" => uid } ) do
3543 application = get_application_for! ( conn , uid )
3644 changeset = OauthApplications . change_application ( application )
45+
3746 render ( conn , "edit.html" , application: application , changeset: changeset )
3847 end
3948
@@ -44,22 +53,24 @@ defmodule PhoenixOauth2Provider.ApplicationController do
4453 { :ok , application } ->
4554 conn
4655 |> put_flash ( :info , "Application updated successfully." )
47- |> redirect ( to: router_helpers ( ) . oauth_application_path ( conn , :show , application ) )
56+ |> redirect ( to: PhoenixOauth2Provider . router_helpers ( ) . oauth_application_path ( conn , :show , application ) )
4857 { :error , % Ecto.Changeset { } = changeset } ->
58+
4959 render ( conn , "edit.html" , application: application , changeset: changeset )
5060 end
5161 end
5262
5363 def delete ( conn , % { "uid" => uid } ) do
54- application = get_application_for! ( conn , uid )
55- { :ok , _application } = OauthApplications . delete_application ( application )
64+ { :ok , _application } = conn
65+ |> get_application_for! ( uid )
66+ |> OauthApplications . delete_application ( )
5667
5768 conn
5869 |> put_flash ( :info , "Application deleted successfully." )
59- |> redirect ( to: router_helpers ( ) . oauth_application_path ( conn , :index ) )
70+ |> redirect ( to: PhoenixOauth2Provider . router_helpers ( ) . oauth_application_path ( conn , :index ) )
6071 end
6172
6273 defp get_application_for! ( conn , uid ) do
63- OauthApplications . get_application_for! ( current_resource_owner ( conn ) , uid )
74+ OauthApplications . get_application_for! ( PhoenixOauth2Provider . current_resource_owner ( conn ) , uid )
6475 end
6576end
0 commit comments