【发布时间】:2019-01-12 00:06:49
【问题描述】:
我有 2 个应用程序,一个用于身份验证,另一个用于产品。登录或验证电子邮件后,用户将被重定向到产品应用程序。在重定向时,最近登录的用户会立即注销,因此对登录用户的引用变为null,我需要在 auth 应用程序中登录凭据才能在第二次进行身份验证。身份验证应用重定向到产品应用后,如何保持登录状态?
这是auth app上的登录功能
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 应用中保持用户的登录状态?
【问题讨论】:
标签: meteor external url-redirection flow-router