Add generate_token method to user