Updated code to authorize user before voting