matrix-dimension/src-ts/matrix/MatrixOpenIdClient.ts
Travis Ralston 4965b61f2d Re-wire the UI to support the new backend
This still doesn't allow editing, but it supports showing the widgets at least.
2017-12-20 21:28:43 -07:00

23 lines
650 B
TypeScript

import * as Promise from "bluebird";
import { doFederatedApiCall } from "./helpers";
import { OpenId } from "../models/OpenId";
export class MatrixOpenIdClient {
constructor(private openId: OpenId) {
}
public getUserId(): Promise<string> {
return doFederatedApiCall(
"GET",
this.openId.matrix_server_name,
"/_matrix/federation/v1/openid/userinfo",
{access_token: this.openId.access_token}
).then(response => {
// Annoyingly, the response isn't JSON for this
response = JSON.parse(response);
return response['sub'];
});
}
}