linotp.tokens.base.stateful_mixin module

A mixin used by token types that have different rollout states (e.g. QRToken and OCRA2)

class linotp.tokens.base.stateful_mixin.StatefulTokenMixin

Bases: object

A mixin used by token types that have different rollout states (e.g. QRToken and OCRA2)

change_state(state_id)

changes the state of this token

Parameters

state_id – The new state_id this token should have

property current_state

signifies the current state of the token

ensure_state(state_id)

a barrier method to ensure that a token has a certain state.

Parameters

state_id – The state the token has to be in

Raises

TokenStateError – If state_id is different from the current state of this token

ensure_state_is_in(valid_state_ids)

a barrier method to ensure that the token state is in a list of valid_states

Parameters

valid_state_ids – A list of allowed states

Raises

TokenStateError – If token state is not in the list of valid states