Created
July 8, 2017 14:28
-
-
Save theoomoregbee/b197d67e780b05428fcba641174dbd5e to your computer and use it in GitHub Desktop.
EVERYTHING YOU NEED TO KNOW ON SECURING YOUR ANGULAR 2+ SPA --> User service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from '@angular/core'; | |
import {IUser} from "../interfaces/iuser"; | |
@Injectable() | |
export class UserService { | |
private user: IUser; | |
constructor() { | |
} | |
/** | |
* this is used to set our user object for current logged in user | |
* @param user | |
*/ | |
set(user: IUser): void { | |
this.user = user; | |
} | |
/** | |
* this is used to get our user | |
* @returns {IUser} | |
*/ | |
get(): IUser { | |
return this.user; | |
} | |
/** | |
* this is used to delete our user stored, by setting it to null | |
*/ | |
delete(): void { | |
this.user = null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment