Merge remote-tracking branch 'Half-Shot/hs/bot-user-type'
This commit is contained in:
commit
6e8bf60050
1 changed files with 6 additions and 3 deletions
|
@ -74,7 +74,8 @@ async def read_client_auth_request(request: web.Request) -> Tuple[Optional[AuthR
|
|||
except KeyError:
|
||||
return None, resp.invalid_server
|
||||
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")
|
||||
|
@ -82,7 +83,7 @@ async def register(request: web.Request) -> web.Response:
|
|||
info, err = await read_client_auth_request(request)
|
||||
if err is not None:
|
||||
return err
|
||||
api, secret, username, password = info
|
||||
api, secret, username, password, user_type = info
|
||||
res = await api.request(Method.GET, Path.admin.register)
|
||||
nonce = res["nonce"]
|
||||
mac = generate_mac(secret, nonce, username, password)
|
||||
|
@ -93,6 +94,8 @@ async def register(request: web.Request) -> web.Response:
|
|||
"password": password,
|
||||
"admin": False,
|
||||
"mac": mac,
|
||||
# Older versions of synapse will ignore this field if it is None
|
||||
"user_type": user_type,
|
||||
}))
|
||||
except MatrixRequestError as e:
|
||||
return web.json_response({
|
||||
|
@ -107,7 +110,7 @@ async def login(request: web.Request) -> web.Response:
|
|||
info, err = await read_client_auth_request(request)
|
||||
if err is not None:
|
||||
return err
|
||||
api, _, username, password = info
|
||||
api, _, username, password, _ = info
|
||||
try:
|
||||
return web.json_response(await api.request(Method.POST, Path.login, content={
|
||||
"type": "m.login.password",
|
||||
|
|
Loading…
Reference in a new issue