In order to fix the reoccuring issue that OpenID users have to add several different OpenID variations, we'll save the usual variations now in different digest fields -> should ease the pain a lot

This commit is contained in:
Oliver Falk
2020-02-25 14:37:03 +01:00
parent 94bd528be2
commit b11495d0b6
6 changed files with 123 additions and 6 deletions

View File

@@ -11,3 +11,25 @@ def random_string(length=10):
'''
return ''.join(random.SystemRandom().choice(
string.ascii_lowercase + string.digits) for _ in range(length))
def openid_variations(openid):
'''
Return the various OpenID variations, ALWAYS in the same order:
- http w/ trailing slash
- http w/o trailing slash
- https w/ trailing slash
- https w/o trailing slash
'''
# Make the 'base' version: http w/ trailing slash
if openid.startswith('https://'):
openid = openid.replace('https://', 'http://')
if openid[-1] != '/':
openid = openid + '/'
# http w/o trailing slash
var1 = openid[0:-1]
var2 = openid.replace('http://', 'https://')
var3 = var2[0:-1]
return (openid, var1, var2, var3)