Improve login code snippet

Many users get confused by an identity object being deleted before the
authentication is finished, therefore the snippet should use heap
allocation.

Change-Id: I7fafe6073680a0c89454e7000fe959ad98bc8b0a
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>