Writing Secure Authentication Logic -