11use std:: { any:: Any , collections:: HashMap , sync:: Arc } ;
22
33use futures:: future:: try_join_all;
4+ use tracing:: warn;
45
56use crate :: {
6- Session , error :: ShieldError , form :: Form , method:: ErasedMethod , options:: ShieldOptions ,
7- storage:: Storage , user:: User ,
7+ action :: ActionForms , error :: ShieldError , method:: ErasedMethod , options:: ShieldOptions ,
8+ session :: Session , storage:: Storage , user:: User ,
89} ;
910
1011#[ derive( Clone ) ]
@@ -68,14 +69,23 @@ impl<U: User> Shield<U> {
6869 & self ,
6970 action_id : & str ,
7071 session : Session ,
71- ) -> Result < Vec < Form > , ShieldError > {
72+ ) -> Result < ActionForms , ShieldError > {
73+ let mut action_name = None :: < String > ;
7274 let mut forms = vec ! [ ] ;
7375
7476 for ( _, method) in self . methods . iter ( ) {
7577 let Some ( action) = method. erased_action_by_id ( action_id) else {
7678 continue ;
7779 } ;
7880
81+ let name = action. erased_name ( ) ;
82+ if let Some ( action_name) = & action_name {
83+ if * action_name != name {
84+ warn ! ( "Action name mismatch `{}` != `{}`" , action_name, name) ;
85+ }
86+ }
87+ action_name = Some ( name) ;
88+
7989 for provider in method. erased_providers ( ) . await ? {
8090 if !action. erased_condition ( & * provider, session. clone ( ) ) ? {
8191 continue ;
@@ -87,7 +97,11 @@ impl<U: User> Shield<U> {
8797 }
8898 }
8999
90- Ok ( forms)
100+ Ok ( ActionForms {
101+ id : action_id. to_owned ( ) ,
102+ name : action_name. unwrap_or ( action_id. to_owned ( ) ) ,
103+ forms,
104+ } )
91105 }
92106}
93107
0 commit comments