Skip to content
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

Add: Emitter event so that other apps know about impersonate #179

Closed
the-djmaze opened this issue Nov 4, 2022 · 3 comments
Closed

Add: Emitter event so that other apps know about impersonate #179

the-djmaze opened this issue Nov 4, 2022 · 3 comments

Comments

@the-djmaze
Copy link

My app has a login system and users have an issue when impersonating, the login doesn't logout.
the-djmaze/snappymail#561

I've tried to create a workaround but that has issues with storing data in session (NC25 might solve this).
nextcloud/server#34935

However, i think it would be better to have an event to listen to for a much better approach.
Can you add an emit() like:

$this->userSession->setUser($user);

		$this->userSession->getManager()->emit('\OC\User', 'impersonate', [$currentUser, $user])
		$this->userSession->setUser($user);

$this->userSession->setUser($user);

		$this->userSession->getManager()->emit('\OC\User', 'impersonate', [$this->userSession->getUser(), $user])
		$this->userSession->setUser($user);
the-djmaze pushed a commit to the-djmaze/snappymail that referenced this issue Nov 4, 2022
@blizzz
Copy link
Member

blizzz commented Nov 4, 2022

should be a typed event nowadays, but generally a PR implemeted this would be accepted.

As a workaround, perhaps checking whether $session->get('oldUserId') (from OCP\ISession) is set could already help.

@the-djmaze
Copy link
Author

the-djmaze commented Nov 4, 2022

As a workaround, perhaps checking whether $session->get('oldUserId') (from OCP\ISession) is set could already help.

That has an issue.

  1. Login Nextcloud
  2. SnappyMail login IMAP
  3. Impersonate
  4. if (oldUserId) SnappyMail->logout()
  5. Login SnappyMail manually
  6. if (oldUserId) SnappyMail->logout()

Step 5 - 6 will then be a repeat, so there must be some kind of permanent check.

  1. SnappyMail keeps track of current IUser (issue with save to session in NC24)
  2. Or just listen to events (also not the best, but doable)

@the-djmaze
Copy link
Author

WIP at #180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants