Compare commits
2 commits
master
...
rxl881/ems
Author | SHA1 | Date | |
---|---|---|---|
|
7c53c85aa5 | ||
|
b274607f41 |
3 changed files with 14 additions and 3 deletions
|
@ -97,7 +97,7 @@ export class SessionContainer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async startWithLogin(homeServer, username, password) {
|
async startWithLogin(homeServer, username, password, guest = false) {
|
||||||
if (this._status.get() !== LoadStatus.NotLoading) {
|
if (this._status.get() !== LoadStatus.NotLoading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,12 @@ export class SessionContainer {
|
||||||
try {
|
try {
|
||||||
const request = this._platform.request;
|
const request = this._platform.request;
|
||||||
const hsApi = new HomeServerApi({homeServer, request});
|
const hsApi = new HomeServerApi({homeServer, request});
|
||||||
const loginData = await hsApi.passwordLogin(username, password, "Hydrogen", {log}).response();
|
let loginData;
|
||||||
|
if (guest === true) {
|
||||||
|
loginData = await hsApi.guestLogin("Hydrogen", {log}).response();
|
||||||
|
} else {
|
||||||
|
loginData = await hsApi.passwordLogin(username, password, "Hydrogen", {log}).response();
|
||||||
|
}
|
||||||
const sessionId = this.createNewSessionId();
|
const sessionId = this.createNewSessionId();
|
||||||
sessionInfo = {
|
sessionInfo = {
|
||||||
id: sessionId,
|
id: sessionId,
|
||||||
|
|
|
@ -142,6 +142,12 @@ export class HomeServerApi {
|
||||||
}, options);
|
}, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guestLogin(initialDeviceDisplayName, options = null) {
|
||||||
|
return this._unauthedRequest("POST", this._url(`/register`), {kind: 'guest'}, {
|
||||||
|
"initial_device_display_name": initialDeviceDisplayName
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
|
||||||
createFilter(userId, filter, options = null) {
|
createFilter(userId, filter, options = null) {
|
||||||
return this._post(`/user/${encodeURIComponent(userId)}/filter`, null, filter, options);
|
return this._post(`/user/${encodeURIComponent(userId)}/filter`, null, filter, options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const container = document.querySelector(".hydrogen");
|
|
||||||
|
|
||||||
export function spinner(t, extraClasses = undefined) {
|
export function spinner(t, extraClasses = undefined) {
|
||||||
|
const container = document.querySelector(".hydrogen");
|
||||||
if (container.classList.contains("legacy")) {
|
if (container.classList.contains("legacy")) {
|
||||||
return t.div({className: "spinner"}, [
|
return t.div({className: "spinner"}, [
|
||||||
t.div(),
|
t.div(),
|
||||||
|
|
Reference in a new issue