Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
infra
ecloud
nextcloud-apps
Ecloud Accounts
Commits
762ed8bd
Commit
762ed8bd
authored
Dec 23, 2021
by
Akhil
😶
Browse files
code formatting
parent
c2e2173e
Changes
5
Hide whitespace changes
Inline
Side-by-side
lib/AppInfo/Application.php
View file @
762ed8bd
...
...
@@ -49,7 +49,7 @@ class Application extends App
$context
->
registerEventListener
(
UserDeletedEvent
::
class
,
UserDeletedListener
::
class
);
}
public
function
boot
(
IBootContext
$context
)
{
public
function
boot
(
IBootContext
$context
)
{
}
}
lib/Controller/UserController.php
View file @
762ed8bd
...
...
@@ -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
;
}
...
...
lib/Events/UserDeletedListener.php
View file @
762ed8bd
<?php
declare
(
strict_types
=
1
);
namespace
OCA\EcloudAccounts\Events
;
...
...
lib/Events/curl.class.php
View file @
762ed8bd
...
...
@@ -85,6 +85,5 @@ class Curl
curl_close
(
$ch
);
return
$response
;
}
}
\ No newline at end of file
}
lib/Service/UserService.php
View file @
762ed8bd
...
...
@@ -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
;
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment