-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18768 from abpframework/sinan/remember_me
Add remember me implementation
- Loading branch information
Showing
5 changed files
with
84 additions
and
46 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
npm/ng-packs/packages/oauth/src/lib/services/remember-me.service.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { AbpLocalStorageService } from '@abp/ng.core'; | ||
import { Injectable, inject } from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class RememberMeService { | ||
readonly #rememberMe = 'remember_me'; | ||
protected readonly localStorageService = inject(AbpLocalStorageService); | ||
|
||
set(remember: boolean) { | ||
this.localStorageService.setItem(this.#rememberMe, JSON.stringify(remember)); | ||
} | ||
|
||
remove() { | ||
this.localStorageService.removeItem(this.#rememberMe); | ||
} | ||
|
||
get() { | ||
return Boolean(JSON.parse(this.localStorageService.getItem(this.#rememberMe))); | ||
} | ||
|
||
getFromToken(accessToken: string) { | ||
const parsedToken = JSON.parse(atob(accessToken.split('.')[1])); | ||
return Boolean(parsedToken[this.#rememberMe]); | ||
} | ||
} |
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
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
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
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