-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Short-term admin accounts #22833 #22837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Short-term admin accounts #22833 #22837
Conversation
Hi @lfolco. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@magento-engcom-team give me test instance |
Hi @sidolov. Thank you for your request. I'm working on Magento instance for you |
Hi @sidolov, here is your new Magento instance. |
Hello @lfolco , |
Yes, I'm running into issues with my tests failing here but not locally. Could use some help! |
I know that this PR has issues with the semantic version checker build, but it's also failing on the static tests build and the functional tests build for stuff that I haven't changed. |
* @method string getExpiresAt() | ||
* @method \Magento\Security\Model\UserExpiration setExpiresAt($value) | ||
*/ | ||
class UserExpiration extends \Magento\Framework\Model\AbstractModel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This model has no interface. The fields are defined in phpdoc. Suggest to introduce and use the interface for expiration model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean create an interface class or define the methods in UserExpiration
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a regular php interface with implementation inside UserExpiration class.
E.g.
interface UserExpirationInterface {
public function getExpiresAt(): string, date or timestamp type
}
class UserExpiration implements UserExpirationInterface {
public function getExpiresAt() {
return 'something';
}
//Some other place
class OtherClass {
public function save(UserExpirationInterface $expiration) {
$expiration->getExpiresAt();
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would I use that in \Magento\Security\Observer\AfterAdminUserSave
, for example? This relies on the abstract model/resource model:
public function execute(Observer $observer)
{
/* @var $user \Magento\User\Model\User */
$user = $observer->getEvent()->getObject();
if ($user->getId()) {
$expiresAt = $user->getExpiresAt();
/** @var \Magento\Security\Model\UserExpiration $userExpiration */
$userExpiration = $this->userExpirationFactory->create();
$this->userExpirationResource->load($userExpiration, $user->getId());
if (empty($expiresAt)) {
// delete it if the admin user clears the field
if ($userExpiration->getId()) {
$this->userExpirationResource->delete($userExpiration);
}
} else {
if (!$userExpiration->getId()) {
$userExpiration->setId($user->getId());
}
$userExpiration->setExpiresAt($expiresAt);
$this->userExpirationResource->save($userExpiration);
}
}
}
Unless I create a repository as well? Or should I not use the new interface in the scenario where I need to load or save the UserExpiration object directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I guess I don't need to do this anymore? I was only asking for clarification, I would have preferred to implement it. I never heard back about my question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lfolco. Sorry for the delay and this accident, I start working on this PR and really want to delivery it.
That is ok that you extend \Magento\Framework\Model\AbstractModel, all that new need it create the interface for this class. We should have a strict contract, currently, contract provided just in phpdoc block, it isn't strict and we have just one option to provide strict contract - it's an interface
f0fc41b
to
932559d
Compare
…t-term admin accounts)
@magento run all tests |
1 similar comment
@magento run all tests |
@magento run all tests |
Hi @VladimirZaets, thank you for the review. |
Hi @lfolco, thank you for your contribution! |
Description (*)
Provides the ability to set an expiration date on admin user accounts, after which the account will be disabled.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Manual testing scenario 1
Manual testing scenario 2
Manual testing scenario 3
Contribution checklist (*)