Extending/modifying ember-用于检查身份验证 cookie 的简单身份验证

Extending/modifying ember-simple-auth to check for auth cookies

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

最后,我希望恢复方法查找在我们的平台之间共享的两个特定的 cookie 安全令牌,并在 localStorage 身份验证数据不存在的情况下作为最后的手段基于这些 cookie 构建简单的 auth localstorage 对象以确定用户是否已通过身份验证。

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

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

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

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

使用重新打开对我有用:

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

export default AdaptiveStore.reopen({
    restore(){
        alert('do custom stuff here');
    }
});