Skip to content

Commit

Permalink
Make loglevel messages from warning to info
Browse files Browse the repository at this point in the history
Make loglevel messages from warning to info.
Trigger messages for successful and
failure only.

Signed-off-by: Sujith H <[email protected]>
  • Loading branch information
sharidas committed May 9, 2017
1 parent 84ca6bd commit bc529be
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions controller/settingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,23 @@ public function impersonate($userid) {
if(\OC::$server->getSession()->get('oldUserId') === null) {
\OC::$server->getSession()->set('oldUserId', $oldUserId);
}
$this->logger->warning("User $oldUserId trying to impersonate user $userid", ['app' => 'impersonate']);

$user = $this->userManager->get($userid);
if ($user === null) {
$this->logger->info("User $userid doesn't exist. User $oldUserId cannot impersonate $userid");
return new JSONResponse([
'error' => 'userNotFound',
'message' => "No user found for $userid"
], Http::STATUS_NOT_FOUND);
} elseif ($this->userManager->get($userid)->getLastLogin() === 0) {
} elseif ($user->getLastLogin() === 0) {
// It's a first time login
$this->logger->info("User $userid did not logged in yet. User $oldUserId cannot impersonate $userid");
return new JSONResponse([
'error' => "userNeverLoggedIn",
'message' => "Cannot impersonate user " . '"' . $userid . '"' . " who hasn't logged in yet.",
], http::STATUS_NOT_FOUND);
} else {
$this->logger->warning("changing to user $userid", ['app' => 'impersonate']);
$this->logger->info("User $oldUserId impersonated user $userid", ['app' => 'impersonate']);
$this->userSession->setUser($user);
}
return new JSONResponse();
Expand Down

0 comments on commit bc529be

Please sign in to comment.