Back
Close

Mission Impossible / How to create datatypes which cannot contain invalid state

adrianimboden
818 views

In this program, the class AuthenticationProcedure implements the logic for the following passwordless login procedure:

  1. The user goes to the login form
  2. The user enters his email address
  3. The user gets an email with a randomly generated token
  4. The user enters the received token on the login form
  5. The user is logged in

Refactor the example with your newly aqcuired knowledge.

Authentication Procedure
// { autofold
#include <boost/assert.hpp>
#include <iostream>
#include <set>
#include <string>
// given
bool send_mail(std::string recipient, std::string token) {
return true;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants