add permission to a view and finish login javascript code