覆盖用户登录方法 [英] Override User afterLogin Method

查看:24
本文介绍了覆盖用户登录方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 yii2 中覆盖 afterLogin 方法?

How to override afterLogin method in yii2?

我应该在哪里写?

protected function afterLogin($identity, $cookieBased, $duration)
{

}

我是 yii2 的新手.请指导我.

I'm New to yii2. Please Guide me.

推荐答案

您需要在 User ActiveRecord 类中实现 afterLogin 方法.

You need to implement the afterLogin method in your User ActiveRecord class.

因此,假设您已经设置了项目,您将在模型文件夹中找到 User 类.

So assuming you have set up your projects you'll find the User class in your models folder.

因此只需将 afterLogin 方法添加到该类中即可执行您需要的任何登录后处理.

So just add the afterLogin method to that class to do whatever post-login processing you need to.

这篇关于覆盖用户登录方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆