@@ -5,6 +5,8 @@ defmodule PhoenixOauth2Provider.ApplicationController do
55 alias ExOauth2Provider.Applications
66 alias Plug.Conn
77
8+ plug :assign_native_redirect_uri when action in [ :new , :create , :edit , :update ]
9+
810 @ spec index ( Conn . t ( ) , map ( ) , map ( ) , keyword ( ) ) :: Conn . t ( )
911 def index ( conn , _params , resource_owner , config ) do
1012 applications = Applications . get_applications_for ( resource_owner , config )
@@ -49,7 +51,7 @@ defmodule PhoenixOauth2Provider.ApplicationController do
4951 application = get_application_for! ( resource_owner , uid , config )
5052 changeset = Applications . change_application ( application , % { } , config )
5153
52- render ( conn , "edit.html" , application: application , changeset: changeset )
54+ render ( conn , "edit.html" , changeset: changeset )
5355 end
5456
5557 @ spec update ( Conn . t ( ) , map ( ) , map ( ) , keyword ( ) ) :: Conn . t ( )
@@ -63,7 +65,7 @@ defmodule PhoenixOauth2Provider.ApplicationController do
6365 |> redirect ( to: Routes . oauth_application_path ( conn , :show , application ) )
6466
6567 { :error , % Ecto.Changeset { } = changeset } ->
66- render ( conn , "edit.html" , application: application , changeset: changeset )
68+ render ( conn , "edit.html" , changeset: changeset )
6769 end
6870 end
6971
@@ -82,4 +84,10 @@ defmodule PhoenixOauth2Provider.ApplicationController do
8284 defp get_application_for! ( resource_owner , uid , config ) do
8385 Applications . get_application_for! ( resource_owner , uid , config )
8486 end
87+
88+ defp assign_native_redirect_uri ( conn , _opts ) do
89+ native_redirect_uri = ExOauth2Provider.Config . native_redirect_uri ( conn . private [ :phoenix_oauth2_provider_config ] )
90+
91+ Conn . assign ( conn , :native_redirect_uri , native_redirect_uri )
92+ end
8593end
0 commit comments