Validate user_code against a [A-Z0-9-] charset before placing it in the /device redirect, closing the CodeQL url-redirection finding (the value can no longer carry path/scheme separators). Split the compound assert flagged by ruff PT018.