Create a qrcode for handles during person creation

main
Bob Mottram 2020-06-21 16:02:52 +00:00
parent e3eec98b4d
commit c1a2f82e80
2 changed files with 21 additions and 1 deletions

View File

@ -493,7 +493,7 @@ class PubServer(BaseHTTPRequestHandler):
if 'HttpOnly;' not in cookieStr: if 'HttpOnly;' not in cookieStr:
if self.server.httpPrefix == 'https': if self.server.httpPrefix == 'https':
cookieStr += '; Secure' cookieStr += '; Secure'
cookieStr += '; HttpOnly; SameSite=Strict' cookieStr += '; HttpOnly; SameSite=Strict'
self.send_header('Cookie', cookieStr) self.send_header('Cookie', cookieStr)
self.send_header('Host', callingDomain) self.send_header('Host', callingDomain)
self.send_header('InstanceID', self.server.instanceId) self.send_header('InstanceID', self.server.instanceId)

View File

@ -10,6 +10,7 @@ import time
import os import os
import subprocess import subprocess
import shutil import shutil
import pyqrcode
from random import randint from random import randint
from pathlib import Path from pathlib import Path
try: try:
@ -380,6 +381,24 @@ def createGroup(baseDir: str, nickname: str, domain: str, port: int,
return privateKeyPem, publicKeyPem, newPerson, webfingerEndpoint return privateKeyPem, publicKeyPem, newPerson, webfingerEndpoint
def savePersonQrcode(baseDir: str,
nickname: str, domain: str, port: int,
scale=6) -> None:
"""Saves a qrcode image for the handle of the person
This helps to transfer onion or i2p handles to a mobile device
"""
qrcodeFilename = baseDir + '/accounts/' + \
nickname + '@' + domain + '/qrcode.png'
if os.path.isfile(qrcodeFilename):
return
handle = '@' + nickname + '@' + domain
if port:
if port != 80 and port != 443:
handle = handle + ':' + str(port)
url = pyqrcode.create(handle)
url.png(qrcodeFilename, scale)
def createPerson(baseDir: str, nickname: str, domain: str, port: int, def createPerson(baseDir: str, nickname: str, domain: str, port: int,
httpPrefix: str, saveToFile: bool, httpPrefix: str, saveToFile: bool,
password=None) -> (str, str, {}, {}): password=None) -> (str, str, {}, {}):
@ -436,6 +455,7 @@ def createPerson(baseDir: str, nickname: str, domain: str, port: int,
registrationsRemaining -= 1 registrationsRemaining -= 1
setConfigParam(baseDir, 'registrationsRemaining', setConfigParam(baseDir, 'registrationsRemaining',
str(registrationsRemaining)) str(registrationsRemaining))
savePersonQrcode(baseDir, nickname, domain, port)
return privateKeyPem, publicKeyPem, newPerson, webfingerEndpoint return privateKeyPem, publicKeyPem, newPerson, webfingerEndpoint