@@ -46,6 +46,7 @@ export class LoginViewModel extends ViewModel<SegmentType, Options> {
4646 private _startSSOLoginViewModel ?: StartSSOLoginViewModel ;
4747 private _completeSSOLoginViewModel ?: CompleteSSOLoginViewModel ;
4848 private _startOIDCLoginViewModel ?: StartOIDCLoginViewModel ;
49+ private _startOIDCGuestLoginViewModel ?: StartOIDCLoginViewModel ;
4950 private _completeOIDCLoginViewModel ?: CompleteOIDCLoginViewModel ;
5051 private _loadViewModel ?: SessionLoadViewModel ;
5152 private _loadViewModelSubscription ?: ( ) => void ;
@@ -85,6 +86,10 @@ export class LoginViewModel extends ViewModel<SegmentType, Options> {
8586 return this . _startOIDCLoginViewModel ;
8687 }
8788
89+ get startOIDCGuestLoginViewModel ( ) : StartOIDCLoginViewModel {
90+ return this . _startOIDCGuestLoginViewModel ;
91+ }
92+
8893 get completeOIDCLoginViewModel ( ) : CompleteOIDCLoginViewModel {
8994 return this . _completeOIDCLoginViewModel ;
9095 }
@@ -169,7 +174,7 @@ export class LoginViewModel extends ViewModel<SegmentType, Options> {
169174
170175 private async _showOIDCLogin ( ) : Promise < void > {
171176 this . _startOIDCLoginViewModel = this . track (
172- new StartOIDCLoginViewModel ( this . childOptions ( { loginOptions : this . _loginOptions } ) )
177+ new StartOIDCLoginViewModel ( this . childOptions ( { loginOptions : this . _loginOptions , asGuest : false } ) )
173178 ) ;
174179 this . emitChange ( "startOIDCLoginViewModel" ) ;
175180 try {
@@ -180,6 +185,19 @@ export class LoginViewModel extends ViewModel<SegmentType, Options> {
180185 }
181186 }
182187
188+ private async _showOIDCGuestLogin ( ) : Promise < void > {
189+ this . _startOIDCGuestLoginViewModel = this . track (
190+ new StartOIDCLoginViewModel ( this . childOptions ( { loginOptions : this . _loginOptions , asGuest : true } ) )
191+ ) ;
192+ this . emitChange ( "startOIDCGuestLoginViewModel" ) ;
193+ try {
194+ await this . _startOIDCLoginViewModel . discover ( ) ;
195+ } catch ( err ) {
196+ this . _showError ( err . message ) ;
197+ this . _disposeViewModels ( ) ;
198+ }
199+ }
200+
183201 private _showError ( message : string ) : void {
184202 this . _errorMessage = message ;
185203 this . emitChange ( "errorMessage" ) ;
@@ -190,6 +208,7 @@ export class LoginViewModel extends ViewModel<SegmentType, Options> {
190208 this . _passwordLoginViewModel ?. setBusy ( status ) ;
191209 this . _startSSOLoginViewModel ?. setBusy ( status ) ;
192210 this . _startOIDCLoginViewModel ?. setBusy ( status ) ;
211+ this . _startOIDCGuestLoginViewModel ?. setBusy ( status ) ;
193212 this . emitChange ( "isBusy" ) ;
194213 }
195214
@@ -244,6 +263,7 @@ export class LoginViewModel extends ViewModel<SegmentType, Options> {
244263 this . _passwordLoginViewModel = this . disposeTracked ( this . _passwordLoginViewModel ) ;
245264 this . _completeSSOLoginViewModel = this . disposeTracked ( this . _completeSSOLoginViewModel ) ;
246265 this . _startOIDCLoginViewModel = this . disposeTracked ( this . _startOIDCLoginViewModel ) ;
266+ this . _startOIDCGuestLoginViewModel = this . disposeTracked ( this . _startOIDCGuestLoginViewModel ) ;
247267 this . emitChange ( "disposeViewModels" ) ;
248268 }
249269
@@ -309,6 +329,7 @@ export class LoginViewModel extends ViewModel<SegmentType, Options> {
309329 if ( this . _loginOptions . sso ) { this . _showSSOLogin ( ) ; }
310330 if ( this . _loginOptions . password ) { this . _showPasswordLogin ( ) ; }
311331 if ( this . _loginOptions . oidc ) { this . _showOIDCLogin ( ) ; }
332+ if ( this . _loginOptions . oidc ?. guestAvailable ) { this . _showOIDCGuestLogin ( ) ; }
312333 if ( ! this . _loginOptions . sso && ! this . _loginOptions . password && ! this . _loginOptions . oidc ) {
313334 this . _showError ( "This homeserver supports neither SSO nor password based login flows or has a usable OIDC Provider" ) ;
314335 }
@@ -335,6 +356,6 @@ export type LoginOptions = {
335356 homeserver : string ;
336357 password ?: ( username : string , password : string ) => PasswordLoginMethod ;
337358 sso ?: SSOLoginHelper ;
338- oidc ?: { issuer : string } ;
359+ oidc ?: { issuer : string , guestAvailable : boolean } ;
339360 token ?: ( loginToken : string ) => TokenLoginMethod ;
340361} ;
0 commit comments