久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

頁(yè)面刷新時(shí),Satellizer 登錄 JWT 令牌消失了

Satellizer login JWT token is gone when page refresh(頁(yè)面刷新時(shí),Satellizer 登錄 JWT 令牌消失了)
本文介紹了頁(yè)面刷新時(shí),Satellizer 登錄 JWT 令牌消失了的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在使用

.controller('loginCtrl', function($scope, $state, $auth, jwtHelper) {$scope.login = 函數(shù)(){$auth.login($scope.user).then(函數(shù)(響應(yīng)){var gelenToken = response.data;var tokenPayload = jwtHelper.decodeToken(gelenToken.token);console.log(JSON.stringify(tokenPayload));//輸出:{"sub":"1","iat":1496346513,"exp":1497556113,"data":{"role":"admin"}}localStorage.setItem('token', JSON.stringify(tokenPayload));$state.go('baba.manga');})};})

解決方案

你應(yīng)該試試這個(gè):

<塊引用>

localStorage.setItem('token', data.token);

<塊引用>

$window.localStorage.token = JSON.stringify(data.token);

要保存您的令牌,您可以在瀏覽器本地存儲(chǔ)中看到該令牌,除非您需要,否則您無需解碼該令牌.

它不應(yīng)該在頁(yè)面刷新時(shí)被刪除,如果它被刪除了,我建議你在地方嘗試斷點(diǎn)并調(diào)試哪個(gè)部分正在清除本地存儲(chǔ).

瀏覽器在任何時(shí)候都不會(huì)刪除任何本地存儲(chǔ)數(shù)據(jù),您的代碼可能正在這樣做.

I am using the Angular-satellizer extension for the login/register feature but I am stuck at number 7.

Token was saved to localStorage but I when refresh the page it's gone and $auth.isAuthenticated() function is returning false.

.controller('loginCtrl', function($scope, $state, $auth, jwtHelper) {
  $scope.login = function() {
    $auth.login($scope.user)
      .then(function(response) {
        var gelenToken = response.data;
        var tokenPayload = jwtHelper.decodeToken(gelenToken.token);
        console.log(JSON.stringify(tokenPayload)); // Output:{"sub":"1","iat":1496346513,"exp":1497556113,"data":{"role":"admin"}}
        localStorage.setItem('token', JSON.stringify(tokenPayload));
        $state.go('baba.manga');
      })
  };
})

解決方案

You should try this :

localStorage.setItem('token', data.token);

OR

$window.localStorage.token = JSON.stringify(data.token);

to save your token, You can see the token in browser local Storage, You don't need to decode that token unless you need it to.

It should not get deleted on page refresh, If its getting deleted the I suggest you to try breakpoints at places and debug which part is clearing local storage.

Browser does not delete any localstorage data at any point, Your code might be doing it.

這篇關(guān)于頁(yè)面刷新時(shí),Satellizer 登錄 JWT 令牌消失了的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Is Math.random() cryptographically secure?(Math.random() 在密碼學(xué)上是安全的嗎?)
Secure random numbers in javascript?(在javascript中保護(hù)隨機(jī)數(shù)?)
How to avoid multiple token refresh requests when making simultaneous API requests with an expired token(使用過期令牌發(fā)出同時(shí) API 請(qǐng)求時(shí)如何避免多個(gè)令牌刷新請(qǐng)求)
JWT not decoding quot;JWT malformedquot; - Node Angular(JWT 未解碼“JWT malformed;- 節(jié)點(diǎn)角度)
How to invalidate a JWT token with no expiry time(如何使沒有到期時(shí)間的 JWT 令牌無效)
Authorization header in img src link(img src 鏈接中的授權(quán)標(biāo)頭)
主站蜘蛛池模板: 欧美自拍日韩 | 亚洲成人一区 | 精品久久中文字幕 | 亚洲精品一二三区 | 成年人黄色小视频 | av网站在线看 | 国产精品美女久久久久aⅴ国产馆 | 日本成人三级电影 | 亚洲一区二区三区视频在线 | 天天天操天天天干 | 狠狠久久综合 | 三级av在线 | 狠狠操狠狠干 | av天天爽 | 日韩久久网| 一级片免费观看 | 三级在线观看 | 日韩在线中文字幕 | 人人干视频在线 | 欧美一区二区免费视频 | 国产美女自拍视频 | 国产99免费 | 九九精品在线 | 中文字幕视频一区 | 久久人| 狠狠做六月爱婷婷综合aⅴ 国产精品视频网 | 在线免费观看黄网 | 一区久久| 日本午夜一区二区三区 | 久久伊| 蜜桃黄网| 免费美女网站 | 午夜精品三区 | 亚洲a一区二区 | 正在播放亚洲 | 午夜精品一区二区三区在线观看 | 亚洲精品免费视频 | 亚洲国产激情 | 精品九九久久 | 国产精品久久久久久久久久妞妞 | 国产精久久久久久久 |