If a user visits our app and the user is already signed in, then we want to redirect the user to the /app
route.
We will be using a Firefly Semantics Slice Object Store to implement the reactive event handling.
Approach
The below onAuthRedirectToApplication
utility method takes a route
argument and directs to it when the user is already signed in.
/**
* Redirect the user to the application
* when the user is authenticated.
* @param route
*/
public onAuthRedirectToApplication(route:string) {
this.s.OS.S.IS_AUTHENTICATED.obs.subscribe(auth => {
auth && this.r.navigate([route])
})
}
Note that when the application loads it should check whether the user is signed in, and if so perform a put
on the Slice Object Store instance modeling the IS_AUTHENTICATED
state. For example:
this.s.OS.put(this.s.OS.S.IS_AUTHENTICATED, true)