def get_device(self, step=None):
if not self.device_cache:<EOL><INDENT>challenge_device_id = self.request.POST.get('<STR_LIT>', None)<EOL>if challenge_device_id:<EOL><INDENT>for device in backup_phones(self.get_user()):<EOL><INDENT>if device.persistent_id == challenge_device_id:<EOL><INDENT>self.device_cache = device<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if step == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>self.device_cache = self.get_user().staticdevice_set.get(name='<STR_LIT>')<EOL><DEDENT>except StaticDevice.DoesNotExist:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if not self.device_cache:<EOL><INDENT>self.device_cache = default_device(self.get_user())<EOL><DEDENT><DEDENT>return self.device_cache<EOL>
Returns the OTP device selected by the user, or his default device.