Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check authentication on each page reload #5859

Open
1 of 3 tasks
frankiedrake opened this issue Jun 18, 2021 · 0 comments
Open
1 of 3 tasks

Check authentication on each page reload #5859

frankiedrake opened this issue Jun 18, 2021 · 0 comments

Comments

@frankiedrake
Copy link

frankiedrake commented Jun 18, 2021

Issue type

I'm submitting a ... (check one with "x")

  • bug report
  • feature request
  • question about the decisions made in the repository

Issue description

Current behavior:
I'm using existing NbPasswordAuthStrategy and after the user becomes authenticated, the auth token successfully stores in localStorage and persists there until explicitly loggin out. Even if I restart by backend (which is implemented in Spring with Spring security), the user is still authenticated on a frontend but gets 401 doing request to a backend.

Expected behavior:
I was expecting that user authority will be checked on each page reload or in some other way (making a call to some /users/me endpoint). Please, suggest me what is the proper way to achieve this.
UPD I can see someone implements this via http interceptors but maybe such behaviour could be added to a framework 'out-of-the-box'.

Steps to reproduce:

  • Authenticate user
  • Restart backend
  • User token still exists in local storage

Related code:
I decided to try to implement custom NbTokenStorage and override desired methods (one of or all of set, get, clear) and sticked into a get method, where I can check if the user is still authenticated on a backend, but this requires to make an http call while method should return a token itself instead of Observable and it seems that I've stand on a wrong path.

Other information:

npm, node, OS, Browser

node v16.3.0
npm 7.15.1
OS Linux (KDE Neon)
Browser: Chrome

Angular, Nebular

{
 ***
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~12.0.3",
    "@angular/cdk": "^12.0.4",
    "@angular/common": "~12.0.3",
    "@angular/compiler": "~12.0.3",
    "@angular/core": "~12.0.3",
    "@angular/forms": "~12.0.3",
    "@angular/platform-browser": "~12.0.3",
    "@angular/platform-browser-dynamic": "~12.0.3",
    "@angular/router": "~12.0.3",
    "@nebular/auth": "^7.0.0",
    "@nebular/eva-icons": "^7.0.0",
    "@nebular/theme": "^7.0.0",
    "bootstrap": "^4.6.0",
    "eva-icons": "^1.1.3",
    "rxjs": "~6.6.0",
    "tslib": "^2.1.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.0.3",
    "@angular/cli": "~12.0.3",
    "@angular/compiler-cli": "~12.0.3",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^12.11.1",
    "jasmine-core": "~3.7.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "typescript": "~4.2.3"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant