forked from mystiq/hydrogen-web
Parse token/sso login in loginOptions
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
66f28b90fc
commit
3fa955e594
1 changed files with 9 additions and 1 deletions
|
@ -24,6 +24,7 @@ import {RequestScheduler} from "./net/RequestScheduler.js";
|
|||
import {Sync, SyncStatus} from "./Sync.js";
|
||||
import {Session} from "./Session.js";
|
||||
import {PasswordLoginMethod} from "./login/PasswordLoginMethod.js";
|
||||
import {TokenLoginMethod} from "./login/TokenLoginMethod.js";
|
||||
|
||||
export const LoadStatus = createEnum(
|
||||
"NotLoading",
|
||||
|
@ -91,7 +92,8 @@ export class SessionContainer {
|
|||
}
|
||||
|
||||
parseLoginOptions(options, homeServer) {
|
||||
/* Take server response and return new object which has two props password and sso which
|
||||
/*
|
||||
Take server response and return new object which has two props password and sso which
|
||||
implements LoginMethod
|
||||
*/
|
||||
const flows = options.flows;
|
||||
|
@ -100,6 +102,12 @@ export class SessionContainer {
|
|||
if (flow.type === "m.login.password") {
|
||||
result.password = (username, password) => new PasswordLoginMethod({homeServer, username, password});
|
||||
}
|
||||
else if (flow.type === "m.login.sso" && flows.find(flow => flow.type === "m.login.token")) {
|
||||
result.sso = loginToken => new TokenLoginMethod({homeServer, loginToken});
|
||||
}
|
||||
else if (flow.type === "m.login.token") {
|
||||
result.token = loginToken => new TokenLoginMethod({homeServer, loginToken});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue