| 
									
										
										
										
											2016-06-09 13:00:26 -05:00
										 |  |  | // #docregion
 | 
					
						
							|  |  |  | import { Injectable } from '@angular/core'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { Observable } from 'rxjs/Observable'; | 
					
						
							|  |  |  | import 'rxjs/add/observable/of'; | 
					
						
							|  |  |  | import 'rxjs/add/operator/do'; | 
					
						
							|  |  |  | import 'rxjs/add/operator/delay'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Injectable() | 
					
						
							|  |  |  | export class AuthService { | 
					
						
							|  |  |  |   isLoggedIn: boolean = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-16 17:34:26 -05:00
										 |  |  |   // store the URL so we can redirect after logging in
 | 
					
						
							|  |  |  |   redirectUrl: string; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-26 23:19:27 -05:00
										 |  |  |   login(): Observable<boolean> { | 
					
						
							| 
									
										
										
										
											2016-06-09 13:00:26 -05:00
										 |  |  |     return Observable.of(true).delay(1000).do(val => this.isLoggedIn = true); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-26 23:19:27 -05:00
										 |  |  |   logout(): void { | 
					
						
							| 
									
										
										
										
											2016-06-09 13:00:26 -05:00
										 |  |  |     this.isLoggedIn = false; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |