channel registrationChannel.
channel loginChannel.
type Login.
type SessionToken.

free ok,nok: bitstring.

event Registered.
event WrongLogin.
event SentToken.
event ReceivedToken.

table logins(Login).
table sessions(SessionToken).

let RegistrationServer() =
  !in(registrationChannel, login: Login);
  insert logins(login);
  out(registrationChannel, ok);
  event Registered.

let LoginServer() =
  !in(loginChannel, login: Login);
  new token: SessionToken;
  get logins( = login) in
    insert sessions(token);
		out(loginChannel, token);
    event SentToken
	else
		event WrongLogin.

let Client() =
  new login: Login;
  out(registrationChannel, login);
  in(registrationChannel, response:bitstring);
  if response = ok then
    out(loginChannel, login);
    in(loginChannel, token: SessionToken);
    event ReceivedToken.

query t:SessionToken; attacker(t).

process RegistrationServer() | LoginServer() |!Client()

(* EXPECTPV
RESULT not attacker(t) is false.
0.008s (user 0.000s + system 0.008s), max rss 7520K
END *)
