src/app/auth/authentication.service.ts
Responsible for saving user name, id and jwt token in localstorage and exposing the name and id through currentUserSubject
Properties |
|
Methods |
Accessors |
constructor(http: HttpClient, router: Router)
|
|||||||||
Defined in src/app/auth/authentication.service.ts:16
|
|||||||||
Parameters :
|
fetchUserFromStorage |
fetchUserFromStorage()
|
Defined in src/app/auth/authentication.service.ts:27
|
Returns :
User
|
login | ||||||||||||
login(username: string, password: string)
|
||||||||||||
Defined in src/app/auth/authentication.service.ts:42
|
||||||||||||
If login is sucessfull save the user name, id and jwt token to local storage and expose the name and id through currentUserSubject. If the login fails the returned observable errors.
Parameters :
Returns :
Observable<User>
the logged in user, errors if login is not successful |
logout |
logout()
|
Defined in src/app/auth/authentication.service.ts:59
|
remove user from local storage and set subject holding the current user to null
Returns :
void
|
saveUserToStorage | ||||||
saveUserToStorage(user: User)
|
||||||
Defined in src/app/auth/authentication.service.ts:31
|
||||||
Parameters :
Returns :
void
|
Public currentUser |
Type : Observable<User>
|
Defined in src/app/auth/authentication.service.ts:16
|
Private currentUserSubject |
Type : BehaviorSubject<User>
|
Defined in src/app/auth/authentication.service.ts:15
|
Readonly userStorageKey |
Type : string
|
Default value : 'currentUser'
|
Defined in src/app/auth/authentication.service.ts:14
|
currentUserValue |
getcurrentUserValue()
|
Defined in src/app/auth/authentication.service.ts:23
|