code from authentication tutorial