Get admin details Magento 2

Facebooktwitterredditpinterestlinkedinmail

To get magento admin details programatically you need to add below mentioned code in your class.


protected $_authSession;

public function __construct(
	...
	\Magento\Backend\Model\Auth\Session $authSession,
	...
) {
	...
	$this->_authSession = $authSession;
	...
}
public function getAdminUser(){
	$user = $this->_authSession->getUser();
	//You will get below mentioned admin information.

	$user->getUserId();
	$user->getFirstname();
	$user->getLastname();
	$user->getEmail();
	$user->getUsername();
	$user->getPassword();
	$user->getCreated();
	$user->getModified();
	$user->getLogdate();
	$user->getLognum();
	$user->getReloadAclFlag();
	$user->getIsActive();
	$user->getExtra();
	$user->getRpToken();
	$user->getRpTokenCreatedAt();
	$user->getInterfaceLocale();
	$user->getFailuresNum();
	$user->getFirstFailure();
	$user->getLockExpires();
}
Facebooktwitterredditpinterestlinkedinmail