Search Posts

Category: cookies

Is it bad security to save jwt in cookie to pass it to local storage?

In order to get my twitter sign in to work with jwt sessions and angularjs, I have created a jwt with twitter username and display name, passed it as a cookie and saved it to local storage. Here’s some relevant code: Log in users and save cookie: app.get(‘/login/twitter’, passport.authenticate(‘twitter’)); app.get(‘/login/twitter/callback’, function(req, res) { passport.authenticate(‘twitter’ , {session: false} , function(err, user, info) { if(err) { console.log(err); } var token; token = user.generateTwitterJwt(); // res.status(200); // res.json({ […]

$cookies.get is not a function – Angular JS

Designed two pages. Cookies is not set and showing error. CDN: <script src = “https://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular.min.js”></script> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular-cookies.js”></script> Main Page – Set Cookies / cookies is not set var app = angular.module(‘myApp’, [‘ngCookies’]); app.controller(‘LoginCtrl’, [‘$cookies’, ‘$scope’, ‘$http’, ‘$window’, ‘$location’, function($cookies,$scope, $http, $window, $location) { $cookies.put(‘username’, ‘name’); } Second Page – Get Cookies var app = angular.module(‘myApp’, [ ‘ngTable’, ‘ngCookies’ , ‘ngResource’]); app.controller(‘AccountMappingCtrl’, [‘$scope’, ‘$http’,’$cookies’, ‘NgTableParams’, function($scope, $http, $filter, $cookies, NgTableParams) { $scope.UsernameCookies = $cookies.get(“username”); } It […]