use referrer url to redirect when authentication success
fix typo
fix
redirect in case of failure
add an options to ignore referrer redirect when success