Thank you for your post.
I'm not a developer of course, but you may want it ordered more like this?
Show Custom Dialog [Title: "Do you want to add materials to your record? if yes" ; Message "Enter your password"] Input Field : Material Password
if [Exact(Materials::Material Password; Materials::Password Field)]
Commit Record/ Request [Skip data entry validation]
Set field [Materials::Password; ""]
Show Custom Dialog [ Title: Message ; Message: "Password unsuccessfull! Try Again"]
Get ( LayoutTableName ) = "Materials" and not PrivExists ( $$Privs ; "Create Material" )
Show Custom Dialog [Title:"Sorry, you do not have the necessary privileges to add New Materials."]
I hope this helps!