* Combine verification and reverification photo submission end-points. * Combine verification and reverification Backbone models. * Allow deletion of verification status in Django admin. * Initial verification from a checkpoint is associated with the checkpoint. * Fix critical bug in which an invalid link was sent to Software Secure for the photo ID image of reverification attempts.
36 lines
671 B
Python
36 lines
671 B
Python
"""
|
|
Image encoding helpers for the verification app.
|
|
"""
|
|
import logging
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
class InvalidImageData(Exception):
|
|
"""
|
|
The provided image data could not be decoded.
|
|
"""
|
|
pass
|
|
|
|
|
|
def decode_image_data(data):
|
|
"""
|
|
Decode base64-encoded image data.
|
|
|
|
Arguments:
|
|
data (str): The raw image data, base64-encoded.
|
|
|
|
Returns:
|
|
str
|
|
|
|
Raises:
|
|
InvalidImageData: The image data could not be decoded.
|
|
|
|
"""
|
|
try:
|
|
return (data.split(",")[1]).decode("base64")
|
|
except (IndexError, UnicodeEncodeError):
|
|
log.exception("Could not decode image data")
|
|
raise InvalidImageData
|