Implementing account authentication from scratch