Merge remote-tracking branch 'Half-Shot/hs/bot-user-type'
This commit is contained in:
commit
6e8bf60050
@ -74,7 +74,8 @@ async def read_client_auth_request(request: web.Request) -> Tuple[Optional[AuthR
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return None, resp.invalid_server
|
return None, resp.invalid_server
|
||||||
api = HTTPAPI(base_url, "", loop=get_loop())
|
api = HTTPAPI(base_url, "", loop=get_loop())
|
||||||
return (api, secret, username, password), None
|
user_type = body.get("user_type", None)
|
||||||
|
return (api, secret, username, password, user_type), None
|
||||||
|
|
||||||
|
|
||||||
@routes.post("/client/auth/{server}/register")
|
@routes.post("/client/auth/{server}/register")
|
||||||
@ -82,7 +83,7 @@ async def register(request: web.Request) -> web.Response:
|
|||||||
info, err = await read_client_auth_request(request)
|
info, err = await read_client_auth_request(request)
|
||||||
if err is not None:
|
if err is not None:
|
||||||
return err
|
return err
|
||||||
api, secret, username, password = info
|
api, secret, username, password, user_type = info
|
||||||
res = await api.request(Method.GET, Path.admin.register)
|
res = await api.request(Method.GET, Path.admin.register)
|
||||||
nonce = res["nonce"]
|
nonce = res["nonce"]
|
||||||
mac = generate_mac(secret, nonce, username, password)
|
mac = generate_mac(secret, nonce, username, password)
|
||||||
@ -93,6 +94,8 @@ async def register(request: web.Request) -> web.Response:
|
|||||||
"password": password,
|
"password": password,
|
||||||
"admin": False,
|
"admin": False,
|
||||||
"mac": mac,
|
"mac": mac,
|
||||||
|
# Older versions of synapse will ignore this field if it is None
|
||||||
|
"user_type": user_type,
|
||||||
}))
|
}))
|
||||||
except MatrixRequestError as e:
|
except MatrixRequestError as e:
|
||||||
return web.json_response({
|
return web.json_response({
|
||||||
@ -107,7 +110,7 @@ async def login(request: web.Request) -> web.Response:
|
|||||||
info, err = await read_client_auth_request(request)
|
info, err = await read_client_auth_request(request)
|
||||||
if err is not None:
|
if err is not None:
|
||||||
return err
|
return err
|
||||||
api, _, username, password = info
|
api, _, username, password, _ = info
|
||||||
try:
|
try:
|
||||||
return web.json_response(await api.request(Method.POST, Path.login, content={
|
return web.json_response(await api.request(Method.POST, Path.login, content={
|
||||||
"type": "m.login.password",
|
"type": "m.login.password",
|
||||||
|
Loading…
Reference in New Issue
Block a user