Skip to content

Instantly share code, notes, and snippets.

@theoomoregbee
Created July 8, 2017 14:28
Show Gist options
  • Save theoomoregbee/b197d67e780b05428fcba641174dbd5e to your computer and use it in GitHub Desktop.
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
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