Commit 762ed8bd authored by Akhil's avatar Akhil 😶
Browse files

code formatting

parent c2e2173e
......@@ -49,7 +49,7 @@ class Application extends App
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
}
public function boot(IBootContext $context) {
public function boot(IBootContext $context)
{
}
}
......@@ -31,19 +31,19 @@ class UserController extends ApiController
$response = new DataResponse();
if(!$this->checkAppCredentials($token)) {
if (!$this->checkAppCredentials($token)) {
$response->setStatus(401);
return $response;
}
if(!$this->userService->userExists($uid)) {
if (!$this->userService->userExists($uid)) {
$response->setStatus(404);
return $response;
return $response;
}
$user = $this->userService->getUser($uid);
if(is_null($user)) {
if (is_null($user)) {
$response->setStatus(404);
return $response;
}
......@@ -52,25 +52,27 @@ class UserController extends ApiController
$user->setQuota($quota);
$recoveryEmailUpdated = $this->userService->setRecoveryEmail($uid, $recoveryEmail);
if(!$recoveryEmailUpdated) {
if (!$recoveryEmailUpdated) {
return $this->getErrorResponse($response, 'error_setting_recovery', 400);
}
$createdFolder = $this->userService->createUserFolder($uid);
if(!$createdFolder){
if (!$createdFolder) {
return $this->getErrorResponse($response, 'error_creating_user_folder', 500);
}
return $response;
}
private function getErrorResponse(DataResponse $response, string $error, int $code) {
private function getErrorResponse(DataResponse $response, string $error, int $code)
{
$response->setStatus($code);
$response->setData(['error' => $error]);
return $response;
}
private function checkAppCredentials(string $token) : bool {
private function checkAppCredentials(string $token): bool
{
$ecloud_accounts_secret = $this->userService->getConfigValue('secret');
return strcmp($token, $ecloud_accounts_secret) === 0;
}
......
<?php
declare(strict_types=1);
namespace OCA\EcloudAccounts\Events;
......
......@@ -85,6 +85,5 @@ class Curl
curl_close($ch);
return $response;
}
}
\ No newline at end of file
}
......@@ -21,7 +21,7 @@ class UserService
/** @var IConfig */
private $config;
public function __construct( $appName, IUserManager $userManager, IConfig $config)
public function __construct($appName, IUserManager $userManager, IConfig $config)
{
$this->userManager = $userManager;
$this->config = $config;
......@@ -34,8 +34,9 @@ class UserService
return $shardingEnabled;
}
public function getConfigValue(string $key) {
if(!empty($this->appConfig[$key])) {
public function getConfigValue(string $key)
{
if (!empty($this->appConfig[$key])) {
return $this->appConfig[$key];
}
return false;
......@@ -47,16 +48,17 @@ class UserService
return $this->userManager->userExists($uid);
}
public function getUser(string $uid) : ?IUser {
public function getUser(string $uid): ?IUser
{
return $this->userManager->get($uid);
}
public function setRecoveryEmail(string $uid, string $recoveryEmail) : bool {
public function setRecoveryEmail(string $uid, string $recoveryEmail): bool
{
try {
$this->config->setUserValue($uid, 'email-recovery', 'recovery-email' ,$recoveryEmail);
$this->config->setUserValue($uid, 'email-recovery', 'recovery-email', $recoveryEmail);
return true;
}
catch(UnexpectedValueException $e) {
} catch (UnexpectedValueException $e) {
return false;
}
}
......@@ -78,8 +80,8 @@ class UserService
return false;
}
// Folder already exists
if (file_exists($ncUserFolder)) {
// Folder already exists
if (file_exists($ncUserFolder)) {
return true;
}
......@@ -105,6 +107,5 @@ class UserService
$this->logger->error("Error while creating user folder and linking for user: " . $uid);
return false;
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment