Search Posts

Category: token

AngularJS – How to store JWT token in $localStorage

I have this service call apiService, in there i can get the token that is generated in the server side. angular.module(‘miniMynd’) .service(‘apiService’, function ($http) { return { loginUser: function(user){ $http.post(“http://localhost:3010/api/login”, user).then(function(response){ console.log(response.data) * I get the token* }) }, } }); my loginCtrl $scope.login = function(){ $apiService.loginUser($scope.credentials); * I pass the crendentials to my function on the client side and i receive a token in the service above* } I have try to put the […]

Token valid jwt angular navbar

I have a little problem. I use nodejs and angular with JWT authentication. When I log out from my account I have an error like this. Auth.guard.ts export class AuthGuard implements CanActivate { constructor(private authService: AuthService, private router: Router){} canActivate(route: ActivatedRouteSnapshot): boolean { if(this.authService.loggedIn()) { this.authService.loggedIn(); return true; } else { this.authService.logoutUser(); return false; } } } Auth.service.ts Verification if the token is present in localStorage getToken(){ const token = localStorage.getItem(‘token’); return token; } Verification […]

How to avoid catching the HTTP OPTIONS request in the express.js auth middleware

Okay I have a backend API built in express.js that responds to a SPA built in AngularJS. I am using token authentication to verify the access of clients to fetch certain resources. The way I check on wether the incoming request from the front-end has an Authorization header containing the Bearer token or not is in an authentication middleware I made myself in express.js. The problem is that AngularJS sends a preflight OPTIONS reuqest before […]

Laravel + AngularJS – oauth 2.0

how to Laravel + AngularJS – oauth 2.0 I work on a project which uses Laravel and AngularJS. My task is to implement a token based auth system. The guy from back end chose to use passport to implement oauth 2.0 and everything works fine. After login and refresh I save the response (token, refresh_token, expires_in) in localStorage. The idea of the whole system is to check, 1 minute before the token expires, if the […]

Add an exception do defaults headers in angularJS

Hello I want to use external API to gather all the current currency rate. My front is based on token and I am storing token in localForage which is nothing but async localStorage. //this execute after every page refresh $localForage.getItem(‘authorization’) .then(function(authData) { if(authData) { $scope.authentication.isAuth = true; $http.defaults.headers.common.Authorization = ‘Bearer ‘ + authData.token; //set authentication variable to true and add token to every request after page refresh } }, function(){ console.log(“error with getting authorization localForage […]

Cors configuration not working spring boot + angular [duplicate]

This question already has an answer here: Response header is present in browser but not parsed by Angular $http response.headers() 2 answers i’m trying to get authentication token from header “autherntication” using angular, but when i use “console.log(response.headers()); i got only 1) cache-control 2) expires 3) pragma in dev tools there are all headers, i tried a log of filters but nothing working 🙁 , thanks for any help ! Fragment of Web configuration @Override […]