Before we can begin to access authentication state, the
Corbado.load()
call has to resolve.
Find more here.One-time access to Authentication State
If you want to access user state once, you can simply callCorbado.sessionToken
,
Corbado.user
or Corbado.isAuthenticated
to get the current user state.
app.component.ts
Subscribing to Authentication State
If you want to synchronize user state to your own state, you can subscribe to theauthStateChanges
and userChanges
observables.
app.component.ts
userId
in the template.
app.component.html
Logout
You can log out the user by callingCorbado.logout
.
app.component.ts
logout
function in your template.
app.component.html