2017-06-27 14 views

回答

-1

我添加了一个启动脚本server/boot下做到这一点

module.exports = function(app) { 
const User = app.models.User; 
timestamp = new Date(); 
User.afterRemote('login', function (ctx, modelInstance, next) { 
    console.log(ctx.req.body.email, 'has logged in at', timestamp); 
    next(); 
}); 
User.afterRemoteError('login', function(ctx, next) { 
    console.log(ctx.req.body.email, 'has unsuccessfully tried to login at', timestamp); 
    next(); 
}); 
} 
-1

docs

扩展内置的用户模型来创建自己的模型,代表用户或客户;此模型提供注册,登录和恢复密码的功能。扩展内置用户模型时,请使用“用户”以外的模型名称,例如“客户”或“客户端”。不要将其命名为“用户”,因为这会与内置的用户模型发生冲突。