Use isinstance and six.text_type to check types of an object.
This commit is contained in:
parent
7ec6994453
commit
20238f54a6
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from oauthlib.oauth1 import (RequestTokenEndpoint, AuthorizationEndpoint,
|
from oauthlib.oauth1 import (RequestTokenEndpoint, AuthorizationEndpoint,
|
||||||
AccessTokenEndpoint)
|
AccessTokenEndpoint)
|
||||||
|
|
||||||
@ -136,7 +138,7 @@ def client_register(request):
|
|||||||
|
|
||||||
contacts = data.get("contacts", None)
|
contacts = data.get("contacts", None)
|
||||||
if contacts is not None:
|
if contacts is not None:
|
||||||
if type(contacts) is not unicode:
|
if not isinstance(contacts, six.text_type):
|
||||||
error = "Contacts must be a string of space-seporated email addresses."
|
error = "Contacts must be a string of space-seporated email addresses."
|
||||||
return json_response({"error": error}, status=400)
|
return json_response({"error": error}, status=400)
|
||||||
|
|
||||||
@ -152,7 +154,7 @@ def client_register(request):
|
|||||||
|
|
||||||
redirect_uris = data.get("redirect_uris", None)
|
redirect_uris = data.get("redirect_uris", None)
|
||||||
if redirect_uris is not None:
|
if redirect_uris is not None:
|
||||||
if type(redirect_uris) is not unicode:
|
if not isinstance(redirect_uris, six.text_type):
|
||||||
error = "redirect_uris must be space-seporated URLs."
|
error = "redirect_uris must be space-seporated URLs."
|
||||||
return json_response({"error": error}, status=400)
|
return json_response({"error": error}, status=400)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user