【问题标题】:Extending/modifying ember-simple-auth to check for auth cookies扩展/修改 ember-simple-auth 以检查身份验证 cookie
【发布时间】:2015-12-15 11:26:46
【问题描述】:

我需要为我的应用修改 ember-simple-auth 中的 adaptive.js

最后,如果 localStorage 身份验证数据尚不存在,我希望恢复方法查找在我们的平台上共享的两个特定 cookie 安全令牌,并基于这些 cookie 构造简单的 auth localstorage 对象,以便确定如果用户已经通过身份验证。

我知道你可以创建一个custom authenticator 但是扩展 Base 的问题是当你的自定义授权方调用还原时,ember-simple-auth 已经为你的身份验证数据查找了本地存储。如果这不可用,则永远不会调用 restore 。出于这个原因,我认为我需要扩展或修改简单的身份验证节点模块以满足我的要求。

下面是我尝试在我的应用程序中修改 ember-simple-auth 中的 Adaptive.js 的简单尝试,但是当调用 restore 时,它​​永远不会通过以下方式:

import AdaptiveStore from 'ember-simple-auth/session-stores/adaptive';

AdaptiveStore.reopenClass({
    restore(){
        alert('do custom stuff here');
    }
});

【问题讨论】:

    标签: ember.js ember-simple-auth


    【解决方案1】:

    使用重新打开对我有用:

    import AdaptiveStore from 'ember-simple-auth/session-stores/adaptive';
    
    export default AdaptiveStore.reopen({
        restore(){
            alert('do custom stuff here');
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多