我有两个应用程序,一个用于身份验证,另一个用于产品。登录或验证电子邮件后,用户将重定向到产品应用程序。在重定向时,最近登录的用户将立即注销,因此对登录用户的引用变为
null
,我需要auth应用程序中的已登录凭据才能在第二天进行身份验证。当auth应用程序重定向到products应用程序时,我如何维护它的登录状态?
这是auth应用程序的登录功能
var callLogin = function (email, password, router) {
Meteor.loginWithPassword(email, password, ( error )=> {
if (error) {
sAlert.error( error );
} else {
sAlert.success("Logged in successfully");
window.location.replace( "http://localhost:3300/" + Meteor.userId() );
}
});
}
这是产品应用程序中的onCreated函数
Tracker.autorun(function () {
let router = FlowRouter.getParam("_id");
let AuthConnection = DDP.connect( AuthURL );
if ( AuthConnection ) {
console.log( router );
AuthConnection.call('logins.user', router, ( error, response )=> {
if ( error ) {
console.log( error );
} console.log( response );
} );
}
});
在重定向为空之前,登录用户始终存在。如何在auth应用程序中维护用户的登录状态?