This is a brilliant way to do what you want

exec() returns if the dialog was accepted or rejected (= canceled) so just use this information and read or do not read the username etc.