Skip to content

Commit

Permalink
Merge pull request #31 from owncloud/fix-loglevel-msg
Browse files Browse the repository at this point in the history
Make loglevel messages from warning to info
  • Loading branch information
Vincent Petry authored May 9, 2017
2 parents 84ca6bd + bc529be commit 6e55300
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 6e55300

Please sign in to comment.