CS auto fixes
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
3b42325d5d
commit
f224b89da3
|
|
@ -26,8 +26,7 @@ namespace OCA\Registration\AppInfo;
|
||||||
use OCP\AppFramework\App;
|
use OCP\AppFramework\App;
|
||||||
|
|
||||||
class Application extends App {
|
class Application extends App {
|
||||||
|
public function __construct(array $urlParams = []) {
|
||||||
public function __construct(array $urlParams = array()) {
|
|
||||||
parent::__construct('registration', $urlParams);
|
parent::__construct('registration', $urlParams);
|
||||||
|
|
||||||
$container = $this->getContainer();
|
$container = $this->getContainer();
|
||||||
|
|
@ -39,5 +38,4 @@ class Application extends App {
|
||||||
$container->registerCapability(\OCA\Registration\Capabilities::class);
|
$container->registerCapability(\OCA\Registration\Capabilities::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
namespace OCA\Registration;
|
namespace OCA\Registration;
|
||||||
|
|
||||||
use OCP\Capabilities\ICapability;
|
|
||||||
use OCP\Capabilities\IPublicCapability;
|
use OCP\Capabilities\IPublicCapability;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
|
|
||||||
|
|
@ -47,5 +46,4 @@ class Capabilities implements IPublicCapability {
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,9 @@ class ApiController extends OCSController {
|
||||||
/** @var Defaults */
|
/** @var Defaults */
|
||||||
private $defaults;
|
private $defaults;
|
||||||
|
|
||||||
const REGISTRATION_STATUS_COMPLETE = 0;
|
public const REGISTRATION_STATUS_COMPLETE = 0;
|
||||||
const REGISTRATION_STATUS_PENDING = 1;
|
public const REGISTRATION_STATUS_PENDING = 1;
|
||||||
const REGISTRATION_STATUS_EXISTING = 2;
|
public const REGISTRATION_STATUS_EXISTING = 2;
|
||||||
|
|
||||||
public function __construct($appName,
|
public function __construct($appName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
|
|
@ -148,7 +148,7 @@ class ApiController extends OCSController {
|
||||||
try {
|
try {
|
||||||
$secret = null;
|
$secret = null;
|
||||||
$registration = $this->registrationService->validateEmail($email);
|
$registration = $this->registrationService->validateEmail($email);
|
||||||
if($registration === true) {
|
if ($registration === true) {
|
||||||
$this->registrationService->validateDisplayname($displayname);
|
$this->registrationService->validateDisplayname($displayname);
|
||||||
$this->registrationService->validateUsername($username);
|
$this->registrationService->validateUsername($username);
|
||||||
$registration = $this->registrationService->createRegistration($email, $username, $password, $displayname);
|
$registration = $this->registrationService->createRegistration($email, $username, $password, $displayname);
|
||||||
|
|
@ -168,7 +168,7 @@ class ApiController extends OCSController {
|
||||||
|
|
||||||
$data['message'] = $this->l10n->t('Your registration is pending. Please confirm your email address.');
|
$data['message'] = $this->l10n->t('Your registration is pending. Please confirm your email address.');
|
||||||
$data['registrationStatus'] = self::REGISTRATION_STATUS_PENDING;
|
$data['registrationStatus'] = self::REGISTRATION_STATUS_PENDING;
|
||||||
if($secret !== null) {
|
if ($secret !== null) {
|
||||||
$data['secret'] = $secret;
|
$data['secret'] = $secret;
|
||||||
}
|
}
|
||||||
return new DataResponse($data, Http::STATUS_OK);
|
return new DataResponse($data, Http::STATUS_OK);
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class RegisterController extends Controller {
|
||||||
IURLGenerator $urlgenerator,
|
IURLGenerator $urlgenerator,
|
||||||
RegistrationService $registrationService,
|
RegistrationService $registrationService,
|
||||||
MailService $mailService
|
MailService $mailService
|
||||||
){
|
) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
$this->urlgenerator = $urlgenerator;
|
$this->urlgenerator = $urlgenerator;
|
||||||
|
|
@ -59,10 +59,10 @@ class RegisterController extends Controller {
|
||||||
* @return TemplateResponse
|
* @return TemplateResponse
|
||||||
*/
|
*/
|
||||||
public function askEmail($errormsg, $entered) {
|
public function askEmail($errormsg, $entered) {
|
||||||
$params = array(
|
$params = [
|
||||||
'errormsg' => $errormsg ? $errormsg : $this->request->getParam('errormsg'),
|
'errormsg' => $errormsg ? $errormsg : $this->request->getParam('errormsg'),
|
||||||
'entered' => $entered ? $entered : $this->request->getParam('entered')
|
'entered' => $entered ? $entered : $this->request->getParam('entered')
|
||||||
);
|
];
|
||||||
return new TemplateResponse('registration', 'register', $params, 'guest');
|
return new TemplateResponse('registration', 'register', $params, 'guest');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,26 +82,26 @@ class RegisterController extends Controller {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$reg = $this->registrationService->validateEmail($email);
|
$reg = $this->registrationService->validateEmail($email);
|
||||||
if ( $reg === true ) {
|
if ($reg === true) {
|
||||||
$registration = $this->registrationService->createRegistration($email);
|
$registration = $this->registrationService->createRegistration($email);
|
||||||
$this->mailService->sendTokenByMail($registration);
|
$this->mailService->sendTokenByMail($registration);
|
||||||
} else {
|
} else {
|
||||||
$this->registrationService->generateNewToken($reg);
|
$this->registrationService->generateNewToken($reg);
|
||||||
$this->mailService->sendTokenByMail($reg);
|
$this->mailService->sendTokenByMail($reg);
|
||||||
return new TemplateResponse('registration', 'message', array('msg' =>
|
return new TemplateResponse('registration', 'message', ['msg' =>
|
||||||
$this->l10n->t('There is already a pending registration with this email, a new verification email has been sent to the address.')
|
$this->l10n->t('There is already a pending registration with this email, a new verification email has been sent to the address.')
|
||||||
), 'guest');
|
], 'guest');
|
||||||
}
|
}
|
||||||
} catch (RegistrationException $e) {
|
} catch (RegistrationException $e) {
|
||||||
return new TemplateResponse('registration', 'message', array('msg' =>
|
return new TemplateResponse('registration', 'message', ['msg' =>
|
||||||
$e->getMessage().'<br/>'.$e->getHint()
|
$e->getMessage().'<br/>'.$e->getHint()
|
||||||
), 'guest');
|
], 'guest');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new TemplateResponse('registration', 'message', array('msg' =>
|
return new TemplateResponse('registration', 'message', ['msg' =>
|
||||||
$this->l10n->t('Verification email successfully sent.')
|
$this->l10n->t('Verification email successfully sent.')
|
||||||
), 'guest');
|
], 'guest');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -130,7 +130,6 @@ class RegisterController extends Controller {
|
||||||
} catch (RegistrationException $exception) {
|
} catch (RegistrationException $exception) {
|
||||||
return $this->renderError($exception->getMessage(), $exception->getHint());
|
return $this->renderError($exception->getMessage(), $exception->getHint());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -152,8 +151,8 @@ class RegisterController extends Controller {
|
||||||
return new TemplateResponse('registration', 'form',
|
return new TemplateResponse('registration', 'form',
|
||||||
[
|
[
|
||||||
'email' => $registration->getEmail(),
|
'email' => $registration->getEmail(),
|
||||||
'entered_data' => array('user' => $username),
|
'entered_data' => ['user' => $username],
|
||||||
'errormsgs' => array($exception->getMessage()),
|
'errormsgs' => [$exception->getMessage()],
|
||||||
'token' => $token
|
'token' => $token
|
||||||
], 'guest');
|
], 'guest');
|
||||||
}
|
}
|
||||||
|
|
@ -166,18 +165,17 @@ class RegisterController extends Controller {
|
||||||
return new TemplateResponse(
|
return new TemplateResponse(
|
||||||
'registration',
|
'registration',
|
||||||
'message',
|
'message',
|
||||||
array('msg' => $this->l10n->t("Your account has been successfully created, but it still needs approval from an administrator.")),
|
['msg' => $this->l10n->t("Your account has been successfully created, but it still needs approval from an administrator.")],
|
||||||
'guest');
|
'guest');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderError($error, $hint="") {
|
private function renderError($error, $hint="") {
|
||||||
return new TemplateResponse('', 'error', array(
|
return new TemplateResponse('', 'error', [
|
||||||
'errors' => array(array(
|
'errors' => [[
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'hint' => $hint
|
'hint' => $hint
|
||||||
))
|
]]
|
||||||
), 'error');
|
], 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class SettingsController extends Controller {
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $appName;
|
protected $appName;
|
||||||
|
|
||||||
public function __construct($appName, IRequest $request, IL10N $l10n, IConfig $config, IGroupManager $groupmanager){
|
public function __construct($appName, IRequest $request, IL10N $l10n, IConfig $config, IGroupManager $groupmanager) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
|
@ -52,9 +52,9 @@ class SettingsController extends Controller {
|
||||||
*/
|
*/
|
||||||
public function admin($registered_user_group, $allowed_domains, $admin_approval_required) {
|
public function admin($registered_user_group, $allowed_domains, $admin_approval_required) {
|
||||||
// handle domains
|
// handle domains
|
||||||
if ( ( $allowed_domains==='' ) || ( $allowed_domains === NULL ) ){
|
if (($allowed_domains==='') || ($allowed_domains === null)) {
|
||||||
$this->config->deleteAppValue($this->appName, 'allowed_domains');
|
$this->config->deleteAppValue($this->appName, 'allowed_domains');
|
||||||
}else{
|
} else {
|
||||||
$this->config->setAppValue($this->appName, 'allowed_domains', $allowed_domains);
|
$this->config->setAppValue($this->appName, 'allowed_domains', $allowed_domains);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,34 +63,34 @@ class SettingsController extends Controller {
|
||||||
|
|
||||||
// handle groups
|
// handle groups
|
||||||
$groups = $this->groupmanager->search('');
|
$groups = $this->groupmanager->search('');
|
||||||
$group_id_list = array();
|
$group_id_list = [];
|
||||||
foreach ( $groups as $group ) {
|
foreach ($groups as $group) {
|
||||||
$group_id_list[] = $group->getGid();
|
$group_id_list[] = $group->getGid();
|
||||||
}
|
}
|
||||||
if ( $registered_user_group === 'none' ) {
|
if ($registered_user_group === 'none') {
|
||||||
$this->config->deleteAppValue($this->appName, 'registered_user_group');
|
$this->config->deleteAppValue($this->appName, 'registered_user_group');
|
||||||
return new DataResponse(array(
|
return new DataResponse([
|
||||||
'data' => array(
|
'data' => [
|
||||||
'message' => (string) $this->l10n->t('Saved'),
|
'message' => (string) $this->l10n->t('Saved'),
|
||||||
),
|
],
|
||||||
'status' => 'success'
|
'status' => 'success'
|
||||||
|
|
||||||
));
|
]);
|
||||||
} else if ( in_array($registered_user_group, $group_id_list) ) {
|
} elseif (in_array($registered_user_group, $group_id_list)) {
|
||||||
$this->config->setAppValue($this->appName, 'registered_user_group', $registered_user_group);
|
$this->config->setAppValue($this->appName, 'registered_user_group', $registered_user_group);
|
||||||
return new DataResponse(array(
|
return new DataResponse([
|
||||||
'data' => array(
|
'data' => [
|
||||||
'message' => (string) $this->l10n->t('Saved'),
|
'message' => (string) $this->l10n->t('Saved'),
|
||||||
),
|
],
|
||||||
'status' => 'success'
|
'status' => 'success'
|
||||||
));
|
]);
|
||||||
} else {
|
} else {
|
||||||
return new DataResponse(array(
|
return new DataResponse([
|
||||||
'data' => array(
|
'data' => [
|
||||||
'message' => (string) $this->l10n->t('No such group'),
|
'message' => (string) $this->l10n->t('No such group'),
|
||||||
),
|
],
|
||||||
'status' => 'error'
|
'status' => 'error'
|
||||||
), Http::STATUS_NOT_FOUND);
|
], Http::STATUS_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -102,7 +102,7 @@ class SettingsController extends Controller {
|
||||||
// handle groups
|
// handle groups
|
||||||
$groups = $this->groupmanager->search('');
|
$groups = $this->groupmanager->search('');
|
||||||
$group_id_list = [];
|
$group_id_list = [];
|
||||||
foreach ( $groups as $group ) {
|
foreach ($groups as $group) {
|
||||||
$group_id_list[] = $group->getGid();
|
$group_id_list[] = $group->getGid();
|
||||||
}
|
}
|
||||||
$current_value = $this->config->getAppValue($this->appName, 'registered_user_group', 'none');
|
$current_value = $this->config->getAppValue($this->appName, 'registered_user_group', 'none');
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ namespace OCA\Registration\Db;
|
||||||
use OCP\AppFramework\Db\Entity;
|
use OCP\AppFramework\Db\Entity;
|
||||||
|
|
||||||
class Registration extends Entity {
|
class Registration extends Entity {
|
||||||
|
|
||||||
public $id;
|
public $id;
|
||||||
protected $email;
|
protected $email;
|
||||||
protected $username;
|
protected $username;
|
||||||
|
|
@ -40,5 +39,4 @@ class Registration extends Entity {
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->addType('emailConfirmed', 'boolean');
|
$this->addType('emailConfirmed', 'boolean');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -97,5 +97,4 @@ class RegistrationMapper extends Mapper {
|
||||||
//FIXME eqivalent to ISecureRandom::CHAR_HUMAN_READABLE introduced in https://github.com/nextcloud/server/commit/f2a2b34e4639e88f8d948a388a51f010212b42a3 but not supported in ownCloud yet. We'll just use the string for now then switch to constants when supported.
|
//FIXME eqivalent to ISecureRandom::CHAR_HUMAN_READABLE introduced in https://github.com/nextcloud/server/commit/f2a2b34e4639e88f8d948a388a51f010212b42a3 but not supported in ownCloud yet. We'll just use the string for now then switch to constants when supported.
|
||||||
$registration->setClientSecret($token);
|
$registration->setClientSecret($token);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class MailService {
|
||||||
* @throws RegistrationException
|
* @throws RegistrationException
|
||||||
*/
|
*/
|
||||||
public function validateEmail($email) {
|
public function validateEmail($email) {
|
||||||
if ( !$this->mailer->validateMailAddress($email) ) {
|
if (!$this->mailer->validateMailAddress($email)) {
|
||||||
throw new RegistrationException($this->l10n->t('The email address you entered is not valid'));
|
throw new RegistrationException($this->l10n->t('The email address you entered is not valid'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +79,7 @@ class MailService {
|
||||||
* @throws RegistrationException
|
* @throws RegistrationException
|
||||||
*/
|
*/
|
||||||
public function sendTokenByMail(Registration $registration) {
|
public function sendTokenByMail(Registration $registration) {
|
||||||
$link = $this->urlGenerator->linkToRoute('registration.register.verifyToken', array('token' => $registration->getToken()));
|
$link = $this->urlGenerator->linkToRoute('registration.register.verifyToken', ['token' => $registration->getToken()]);
|
||||||
$link = $this->urlGenerator->getAbsoluteURL($link);
|
$link = $this->urlGenerator->getAbsoluteURL($link);
|
||||||
$template_var = [
|
$template_var = [
|
||||||
'link' => $link,
|
'link' => $link,
|
||||||
|
|
@ -99,7 +99,7 @@ class MailService {
|
||||||
$message->setPlainBody($plaintext_part);
|
$message->setPlainBody($plaintext_part);
|
||||||
$message->setHtmlBody($html_part);
|
$message->setHtmlBody($html_part);
|
||||||
$failed_recipients = $this->mailer->send($message);
|
$failed_recipients = $this->mailer->send($message);
|
||||||
if ( !empty($failed_recipients) ) {
|
if (!empty($failed_recipients)) {
|
||||||
throw new RegistrationException($this->l10n->t('A problem occurred sending email, please contact your administrator.'));
|
throw new RegistrationException($this->l10n->t('A problem occurred sending email, please contact your administrator.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -125,10 +125,10 @@ class MailService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$to_arr = array();
|
$to_arr = [];
|
||||||
foreach ( $admin_users as $au ) {
|
foreach ($admin_users as $au) {
|
||||||
$au_email = $au->getEMailAddress();
|
$au_email = $au->getEMailAddress();
|
||||||
if ( $au_email && $au->isEnabled()) {
|
if ($au_email && $au->isEnabled()) {
|
||||||
$to_arr[$au_email] = $au->getDisplayName();
|
$to_arr[$au_email] = $au->getDisplayName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,7 +147,7 @@ class MailService {
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
private function sendNewUserNotifEmail(array $to, $username, $userIsEnabled) {
|
private function sendNewUserNotifEmail(array $to, $username, $userIsEnabled) {
|
||||||
if ( $this->config->getAppValue('core', 'vendor', '') === 'nextcloud' ) {
|
if ($this->config->getAppValue('core', 'vendor', '') === 'nextcloud') {
|
||||||
$link = $this->urlGenerator->linkToRouteAbsolute('settings.Users.usersList');
|
$link = $this->urlGenerator->linkToRouteAbsolute('settings.Users.usersList');
|
||||||
} else {
|
} else {
|
||||||
$link = $this->urlGenerator->linkToRouteAbsolute('user_management.users');
|
$link = $this->urlGenerator->linkToRouteAbsolute('user_management.users');
|
||||||
|
|
@ -182,8 +182,8 @@ class MailService {
|
||||||
$message->setPlainBody($plaintext_part);
|
$message->setPlainBody($plaintext_part);
|
||||||
$message->setHtmlBody($html_part);
|
$message->setHtmlBody($html_part);
|
||||||
$failed_recipients = $this->mailer->send($message);
|
$failed_recipients = $this->mailer->send($message);
|
||||||
if ( !empty($failed_recipients) )
|
if (!empty($failed_recipients)) {
|
||||||
throw new RegistrationException('Failed recipients: '.print_r($failed_recipients, true));
|
throw new RegistrationException('Failed recipients: '.print_r($failed_recipients, true));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
namespace OCA\Registration\Service;
|
namespace OCA\Registration\Service;
|
||||||
|
|
||||||
class RegistrationException extends \Exception {
|
class RegistrationException extends \Exception {
|
||||||
|
|
||||||
protected $hint;
|
protected $hint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -45,5 +44,4 @@ class RegistrationException extends \Exception {
|
||||||
public function getHint() {
|
public function getHint() {
|
||||||
return $this->hint;
|
return $this->hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -87,7 +87,7 @@ class RegistrationService {
|
||||||
|
|
||||||
public function __construct($appName, MailService $mailService, IL10N $l10n, IURLGenerator $urlGenerator,
|
public function __construct($appName, MailService $mailService, IL10N $l10n, IURLGenerator $urlGenerator,
|
||||||
RegistrationMapper $registrationMapper, IUserManager $userManager, IConfig $config, IGroupManager $groupManager, Defaults $defaults,
|
RegistrationMapper $registrationMapper, IUserManager $userManager, IConfig $config, IGroupManager $groupManager, Defaults $defaults,
|
||||||
ISecureRandom $random, IUserSession $us, IRequest $request, ILogger $logger, ISession $session, IProvider $tokenProvider, ICrypto $crypto){
|
ISecureRandom $random, IUserSession $us, IRequest $request, ILogger $logger, ISession $session, IProvider $tokenProvider, ICrypto $crypto) {
|
||||||
$this->appName = $appName;
|
$this->appName = $appName;
|
||||||
$this->mailService = $mailService;
|
$this->mailService = $mailService;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
|
|
@ -134,13 +134,14 @@ class RegistrationService {
|
||||||
$registration->setEmail($email);
|
$registration->setEmail($email);
|
||||||
$registration->setUsername($username);
|
$registration->setUsername($username);
|
||||||
$registration->setDisplayname($displayname);
|
$registration->setDisplayname($displayname);
|
||||||
if($password !== "") {
|
if ($password !== "") {
|
||||||
$password = $this->crypto->encrypt($password);
|
$password = $this->crypto->encrypt($password);
|
||||||
$registration->setPassword($password);
|
$registration->setPassword($password);
|
||||||
}
|
}
|
||||||
$this->registrationMapper->generateNewToken($registration);
|
$this->registrationMapper->generateNewToken($registration);
|
||||||
if ( $password !== '' && $username !== '' )
|
if ($password !== '' && $username !== '') {
|
||||||
$this->registrationMapper->generateClientSecret($registration);
|
$this->registrationMapper->generateClientSecret($registration);
|
||||||
|
}
|
||||||
$this->registrationMapper->insert($registration);
|
$this->registrationMapper->insert($registration);
|
||||||
return $registration;
|
return $registration;
|
||||||
}
|
}
|
||||||
|
|
@ -151,15 +152,15 @@ class RegistrationService {
|
||||||
* @throws RegistrationException
|
* @throws RegistrationException
|
||||||
*/
|
*/
|
||||||
public function validateEmail($email) {
|
public function validateEmail($email) {
|
||||||
|
|
||||||
$this->mailService->validateEmail($email);
|
$this->mailService->validateEmail($email);
|
||||||
|
|
||||||
// check for pending registrations
|
// check for pending registrations
|
||||||
try {
|
try {
|
||||||
return $this->registrationMapper->find($email);//if not found DB will throw a exception
|
return $this->registrationMapper->find($email);//if not found DB will throw a exception
|
||||||
} catch (DoesNotExistException $e) {}
|
} catch (DoesNotExistException $e) {
|
||||||
|
}
|
||||||
|
|
||||||
if ( $this->userManager->getByEmail($email) ) {
|
if ($this->userManager->getByEmail($email)) {
|
||||||
throw new RegistrationException(
|
throw new RegistrationException(
|
||||||
$this->l10n->t('A user has already taken this email, maybe you already have an account?'),
|
$this->l10n->t('A user has already taken this email, maybe you already have an account?'),
|
||||||
$this->l10n->t('You can <a href="%s">log in now</a>.', [$this->urlGenerator->getAbsoluteURL('/')])
|
$this->l10n->t('You can <a href="%s">log in now</a>.', [$this->urlGenerator->getAbsoluteURL('/')])
|
||||||
|
|
@ -182,7 +183,7 @@ class RegistrationService {
|
||||||
* @throws RegistrationException
|
* @throws RegistrationException
|
||||||
*/
|
*/
|
||||||
public function validateDisplayname($displayname) {
|
public function validateDisplayname($displayname) {
|
||||||
if($displayname === "") {
|
if ($displayname === "") {
|
||||||
throw new RegistrationException($this->l10n->t('Please provide a valid display name.'));
|
throw new RegistrationException($this->l10n->t('Please provide a valid display name.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -192,11 +193,11 @@ class RegistrationService {
|
||||||
* @throws RegistrationException
|
* @throws RegistrationException
|
||||||
*/
|
*/
|
||||||
public function validateUsername($username) {
|
public function validateUsername($username) {
|
||||||
if($username === "") {
|
if ($username === "") {
|
||||||
throw new RegistrationException($this->l10n->t('Please provide a valid user name.'));
|
throw new RegistrationException($this->l10n->t('Please provide a valid user name.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->registrationMapper->usernameIsPending($username) || $this->userManager->get($username) !== null) {
|
if ($this->registrationMapper->usernameIsPending($username) || $this->userManager->get($username) !== null) {
|
||||||
throw new RegistrationException($this->l10n->t('The username you have chosen already exists.'));
|
throw new RegistrationException($this->l10n->t('The username you have chosen already exists.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -209,7 +210,7 @@ class RegistrationService {
|
||||||
*/
|
*/
|
||||||
public function checkAllowedDomains($email) {
|
public function checkAllowedDomains($email) {
|
||||||
$allowed_domains = $this->config->getAppValue($this->appName, 'allowed_domains', '');
|
$allowed_domains = $this->config->getAppValue($this->appName, 'allowed_domains', '');
|
||||||
if ( $allowed_domains !== '' ) {
|
if ($allowed_domains !== '') {
|
||||||
$allowed_domains = explode(';', $allowed_domains);
|
$allowed_domains = explode(';', $allowed_domains);
|
||||||
$allowed = false;
|
$allowed = false;
|
||||||
foreach ($allowed_domains as $domain) {
|
foreach ($allowed_domains as $domain) {
|
||||||
|
|
@ -257,7 +258,7 @@ class RegistrationService {
|
||||||
* @throws RegistrationException|\InvalidTokenException
|
* @throws RegistrationException|\InvalidTokenException
|
||||||
*/
|
*/
|
||||||
public function createAccount(Registration &$registration, $username = null, $password = null) {
|
public function createAccount(Registration &$registration, $username = null, $password = null) {
|
||||||
if($password === null && $registration->getPassword() === null) {
|
if ($password === null && $registration->getPassword() === null) {
|
||||||
$generatedPassword = $this->generateRandomDeviceToken();
|
$generatedPassword = $this->generateRandomDeviceToken();
|
||||||
$registration->setPassword($this->crypto->encrypt($generatedPassword));
|
$registration->setPassword($this->crypto->encrypt($generatedPassword));
|
||||||
}
|
}
|
||||||
|
|
@ -266,7 +267,7 @@ class RegistrationService {
|
||||||
$username = $registration->getUsername();
|
$username = $registration->getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($registration->getPassword() !== null) {
|
if ($registration->getPassword() !== null) {
|
||||||
$password = $this->crypto->decrypt($registration->getPassword());
|
$password = $this->crypto->decrypt($registration->getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -293,9 +294,9 @@ class RegistrationService {
|
||||||
|
|
||||||
// Add user to group
|
// Add user to group
|
||||||
$registered_user_group = $this->config->getAppValue($this->appName, 'registered_user_group', 'none');
|
$registered_user_group = $this->config->getAppValue($this->appName, 'registered_user_group', 'none');
|
||||||
if ( $registered_user_group !== 'none' ) {
|
if ($registered_user_group !== 'none') {
|
||||||
$group = $this->groupManager->get($registered_user_group);
|
$group = $this->groupManager->get($registered_user_group);
|
||||||
if ( $group === null ) {
|
if ($group === null) {
|
||||||
// This might happen if $registered_user_group is deleted after setting the value
|
// This might happen if $registered_user_group is deleted after setting the value
|
||||||
// Here I choose to log error instead of stopping the user to register
|
// Here I choose to log error instead of stopping the user to register
|
||||||
$this->logger->error("You specified newly registered users be added to '$registered_user_group' group, but it does not exist.");
|
$this->logger->error("You specified newly registered users be added to '$registered_user_group' group, but it does not exist.");
|
||||||
|
|
@ -318,7 +319,7 @@ class RegistrationService {
|
||||||
// with client secret implies registered via API
|
// with client secret implies registered via API
|
||||||
// without client secret implies registered via form
|
// without client secret implies registered via form
|
||||||
// if registered via API, the registration request will be deleted in apicontroller::status
|
// if registered via API, the registration request will be deleted in apicontroller::status
|
||||||
if($registration->getClientSecret() === null) {
|
if ($registration->getClientSecret() === null) {
|
||||||
$res = $this->registrationMapper->delete($registration);
|
$res = $this->registrationMapper->delete($registration);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
throw new RegistrationException($this->l10n->t('Failed to delete pending registration request'));
|
throw new RegistrationException($this->l10n->t('Failed to delete pending registration request'));
|
||||||
|
|
@ -417,7 +418,7 @@ class RegistrationService {
|
||||||
if ($decrypt) {
|
if ($decrypt) {
|
||||||
$password = $this->crypto->decrypt($password);
|
$password = $this->crypto->decrypt($password);
|
||||||
}
|
}
|
||||||
if ( method_exists($this->usersession, 'createSessionToken') ) {
|
if (method_exists($this->usersession, 'createSessionToken')) {
|
||||||
$this->usersession->login($username, $password);
|
$this->usersession->login($username, $password);
|
||||||
$this->usersession->createSessionToken($this->request, $userId, $username, $password);
|
$this->usersession->createSessionToken($this->request, $userId, $username, $password);
|
||||||
return new RedirectResponse($this->urlGenerator->linkTo('', 'index.php'));
|
return new RedirectResponse($this->urlGenerator->linkTo('', 'index.php'));
|
||||||
|
|
@ -434,7 +435,6 @@ class RegistrationService {
|
||||||
['msg' => $this->l10n->t('Your account has been successfully created, you can <a href="%s">log in now</a>.', [$this->urlGenerator->getAbsoluteURL('/')])]
|
['msg' => $this->l10n->t('Your account has been successfully created, you can <a href="%s">log in now</a>.', [$this->urlGenerator->getAbsoluteURL('/')])]
|
||||||
, 'guest'
|
, 'guest'
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -451,5 +451,4 @@ class RegistrationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace OCA\Registration\Settings;
|
namespace OCA\Registration\Settings;
|
||||||
|
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
|
||||||
use OCP\Settings\ISettings;
|
use OCP\Settings\ISettings;
|
||||||
|
|
||||||
use OCA\Registration\Controller\SettingsController;
|
use OCA\Registration\Controller\SettingsController;
|
||||||
|
|
@ -31,5 +31,3 @@ class RegistrationSettings implements ISettings {
|
||||||
return $this->getSection();
|
return $this->getSection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
namespace OCA\Registration\Util;
|
namespace OCA\Registration\Util;
|
||||||
|
|
||||||
class CoreBridge
|
class CoreBridge {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* This function maps an exception class to the available exception class of the core
|
* This function maps an exception class to the available exception class of the core
|
||||||
* in order to provide cross-core and cross-version compatibility.
|
* in order to provide cross-core and cross-version compatibility.
|
||||||
|
|
@ -12,8 +11,7 @@ class CoreBridge
|
||||||
* @return string
|
* @return string
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
*/
|
*/
|
||||||
public static function exceptionClass($className)
|
public static function exceptionClass($className) {
|
||||||
{
|
|
||||||
static $classes = [
|
static $classes = [
|
||||||
'OCSException' => [
|
'OCSException' => [
|
||||||
'OCP\AppFramework\OCS\OCSException',
|
'OCP\AppFramework\OCS\OCSException',
|
||||||
|
|
@ -52,8 +50,7 @@ class CoreBridge
|
||||||
* @param null|int $code
|
* @param null|int $code
|
||||||
* @return \Exception
|
* @return \Exception
|
||||||
*/
|
*/
|
||||||
public static function createException($className, $message = null, $code = null)
|
public static function createException($className, $message = null, $code = null) {
|
||||||
{
|
|
||||||
$exceptionClassName = self::exceptionClass($className);
|
$exceptionClassName = self::exceptionClass($className);
|
||||||
|
|
||||||
$reflection = new \ReflectionClass($exceptionClassName);
|
$reflection = new \ReflectionClass($exceptionClassName);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ script('registration', 'settings');
|
||||||
<select id="registered_user_group" name="registered_user_group">
|
<select id="registered_user_group" name="registered_user_group">
|
||||||
<option value="none" <?php echo $_['current'] === 'none' ? 'selected="selected"' : ''; ?>><?php p($l->t('None')); ?></option>
|
<option value="none" <?php echo $_['current'] === 'none' ? 'selected="selected"' : ''; ?>><?php p($l->t('None')); ?></option>
|
||||||
<?php
|
<?php
|
||||||
foreach ( $_['groups'] as $group ) {
|
foreach ($_['groups'] as $group) {
|
||||||
$selected = $_['current'] === $group ? 'selected="selected"' : '';
|
$selected = $_['current'] === $group ? 'selected="selected"' : '';
|
||||||
echo '<option value="'.$group.'" '.$selected.'>'.$group.'</option>';
|
echo '<option value="'.$group.'" '.$selected.'>'.$group.'</option>';
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,9 @@ foreach ( $_['groups'] as $group ) {
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<label for="admin_approval_required"><?php p($l->t('Require admin approval?')); ?>
|
<label for="admin_approval_required"><?php p($l->t('Require admin approval?')); ?>
|
||||||
<input type="checkbox" id="admin_approval_required" name="admin_approval_required" <?php if($_['approval_required'] === "yes" ) echo " checked"; ?>>
|
<input type="checkbox" id="admin_approval_required" name="admin_approval_required" <?php if ($_['approval_required'] === "yes") {
|
||||||
|
echo " checked";
|
||||||
|
} ?>>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<ul class="error-wide">
|
<ul class="error-wide">
|
||||||
<li class='error'><?php p($l->t('Registration is only allowed for the following domains:')); ?>
|
<li class='error'><?php p($l->t('Registration is only allowed for the following domains:')); ?>
|
||||||
<?php
|
<?php
|
||||||
foreach ($_['domains'] as $domain ){
|
foreach ($_['domains'] as $domain) {
|
||||||
echo "<p class='hint'>";
|
echo "<p class='hint'>";
|
||||||
p($domain);
|
p($domain);
|
||||||
echo "</p>";
|
echo "</p>";
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo $l->t('A new user "%s" has created an account on %s and awaits admin approbation', [$_['user'], $_['sitename']]);
|
echo $l->t('A new user "%s" has created an account on %s and awaits admin approbation', [$_['user'], $_['sitename']]);
|
||||||
echo str_replace('{link}', $_['link'], '<br/><br/><a href="{link}">{link}</a>');
|
echo str_replace('{link}', $_['link'], '<br/><br/><a href="{link}">{link}</a>');
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo $l->t('A new user "%s" has created an account on %s and awaits admin approbation', [$_['user'], $_['sitename']]);
|
echo $l->t('A new user "%s" has created an account on %s and awaits admin approbation', [$_['user'], $_['sitename']]);
|
||||||
echo "\n\n".$_['link'];
|
echo "\n\n".$_['link'];
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo $l->t('A new user "%s" has created an account on %s', [$_['user'], $_['sitename']]);
|
echo $l->t('A new user "%s" has created an account on %s', [$_['user'], $_['sitename']]);
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo $l->t('A new user "%s" has created an account on %s', [$_['user'], $_['sitename']]);
|
echo $l->t('A new user "%s" has created an account on %s', [$_['user'], $_['sitename']]);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo $l->t('To create a new account on %s, just click the following link:', [$_['sitename']]);
|
echo $l->t('To create a new account on %s, just click the following link:', [$_['sitename']]);
|
||||||
echo str_replace('{link}', $_['link'], '<br/><br/><a href="{link}">{link}</a>');
|
echo str_replace('{link}', $_['link'], '<br/><br/><a href="{link}">{link}</a>');
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo $l->t("To create a new account on %s, just click the following link:", [$_['sitename']]);
|
echo $l->t("To create a new account on %s, just click the following link:", [$_['sitename']]);
|
||||||
echo "\n\n".$_['link'];
|
echo "\n\n".$_['link'];
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
\OCP\Util::addStyle('registration', 'style');
|
\OCP\Util::addStyle('registration', 'style');
|
||||||
\OCP\Util::addScript('registration', 'form');
|
\OCP\Util::addScript('registration', 'form');
|
||||||
if ( \OCP\Util::getVersion()[0] >= 12 )
|
if (\OCP\Util::getVersion()[0] >= 12) {
|
||||||
\OCP\Util::addStyle('core', 'guest');
|
\OCP\Util::addStyle('core', 'guest');
|
||||||
?><form action="<?php print_unescaped(\OC::$server->getURLGenerator()->linkToRoute('registration.register.createAccount', array('token'=>$_['token']))) ?>" method="post">
|
}
|
||||||
|
?><form action="<?php print_unescaped(\OC::$server->getURLGenerator()->linkToRoute('registration.register.createAccount', ['token'=>$_['token']])) ?>" method="post">
|
||||||
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
|
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<?php if ( !empty($_['errormsgs']) ) {?>
|
<?php if (!empty($_['errormsgs'])) {?>
|
||||||
<ul class="error">
|
<ul class="error">
|
||||||
<?php foreach ( $_['errormsgs'] as $errormsg ) { ?>
|
<?php foreach ($_['errormsgs'] as $errormsg) { ?>
|
||||||
<li><?php p($errormsg); ?></li>
|
<li><?php p($errormsg); ?></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -24,16 +25,18 @@ if ( \OCP\Util::getVersion()[0] >= 12 )
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="groupmiddle">
|
<p class="groupmiddle">
|
||||||
<input type="text" name="username" id="username" value="<?php if (!empty($_['entered_data']['user'])) { p($_['entered_data']['user']); } ?>" placeholder="<?php p($l->t('Username')); ?>" />
|
<input type="text" name="username" id="username" value="<?php if (!empty($_['entered_data']['user'])) {
|
||||||
|
p($_['entered_data']['user']);
|
||||||
|
} ?>" placeholder="<?php p($l->t('Username')); ?>" />
|
||||||
<label for="username" class="infield"><?php p($l->t('Username')); ?></label>
|
<label for="username" class="infield"><?php p($l->t('Username')); ?></label>
|
||||||
<img id="username-icon" class="svg" src="<?php print_unescaped(image_path('', 'actions/user.svg')); ?>" alt=""/>
|
<img id="username-icon" class="svg" src="<?php print_unescaped(image_path('', 'actions/user.svg')); ?>" alt=""/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="groupbottom">
|
<p class="groupbottom">
|
||||||
<input type="password" name="password" id="password" placeholder="<?php p($l->t('Password')); ?>"/>
|
<input type="password" name="password" id="password" placeholder="<?php p($l->t('Password')); ?>"/>
|
||||||
<label for="password" class="infield"><?php p($l->t( 'Password' )); ?></label>
|
<label for="password" class="infield"><?php p($l->t('Password')); ?></label>
|
||||||
<img id="password-icon" class="svg" src="<?php print_unescaped(image_path('', 'actions/password.svg')); ?>" alt=""/>
|
<img id="password-icon" class="svg" src="<?php print_unescaped(image_path('', 'actions/password.svg')); ?>" alt=""/>
|
||||||
<?php if ( \OC::$server->getConfig()->getAppValue('core', 'vendor', '') === 'nextcloud' ) { ?>
|
<?php if (\OC::$server->getConfig()->getAppValue('core', 'vendor', '') === 'nextcloud') { ?>
|
||||||
<input id="show" name="show" type="checkbox">
|
<input id="show" name="show" type="checkbox">
|
||||||
<label id="show-password" style="display: inline;" for="show"></label>
|
<label id="show-password" style="display: inline;" for="show"></label>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
\OCP\Util::addStyle('registration', 'style');
|
\OCP\Util::addStyle('registration', 'style');
|
||||||
if ( \OCP\Util::getVersion()[0] >= 12 )
|
if (\OCP\Util::getVersion()[0] >= 12) {
|
||||||
\OCP\Util::addStyle('core', 'guest')
|
\OCP\Util::addStyle('core', 'guest');
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<ul class="msg error-wide nc-theming-main-text">
|
<ul class="msg error-wide nc-theming-main-text">
|
||||||
<li><?php print_unescaped($_['msg'])?></li>
|
<li><?php print_unescaped($_['msg'])?></li>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
\OCP\Util::addStyle('registration', 'style');
|
\OCP\Util::addStyle('registration', 'style');
|
||||||
if ( \OCP\Util::getVersion()[0] >= 12 )
|
if (\OCP\Util::getVersion()[0] >= 12) {
|
||||||
\OCP\Util::addStyle('core', 'guest');
|
\OCP\Util::addStyle('core', 'guest');
|
||||||
|
}
|
||||||
if ($_['entered']): ?>
|
if ($_['entered']): ?>
|
||||||
<?php if (empty($_['errormsg'])): ?>
|
<?php if (empty($_['errormsg'])): ?>
|
||||||
<ul class="success">
|
<ul class="success">
|
||||||
|
|
@ -17,7 +18,7 @@ if ($_['entered']): ?>
|
||||||
</ul>
|
</ul>
|
||||||
<p class="groupofone">
|
<p class="groupofone">
|
||||||
<input type="email" name="email" id="email" placeholder="<?php p($l->t('Email')); ?>" value="" required autofocus />
|
<input type="email" name="email" id="email" placeholder="<?php p($l->t('Email')); ?>" value="" required autofocus />
|
||||||
<label for="email" class="infield"><?php p($l->t( 'Email' )); ?></label>
|
<label for="email" class="infield"><?php p($l->t('Email')); ?></label>
|
||||||
<img id="email-icon" class="svg" src="<?php print_unescaped(image_path('', 'actions/mail.svg')); ?>" alt=""/>
|
<img id="email-icon" class="svg" src="<?php print_unescaped(image_path('', 'actions/mail.svg')); ?>" alt=""/>
|
||||||
</p>
|
</p>
|
||||||
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']); ?>" />
|
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']); ?>" />
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,9 @@
|
||||||
|
|
||||||
namespace OCA\Registration\Tests\Integration\Controller;
|
namespace OCA\Registration\Tests\Integration\Controller;
|
||||||
|
|
||||||
use OCA\Registration\Db\Registration;
|
|
||||||
use OCA\Registration\Db\RegistrationMapper;
|
use OCA\Registration\Db\RegistrationMapper;
|
||||||
use OCA\Registration\Service\MailService;
|
use OCA\Registration\Service\MailService;
|
||||||
use OCA\Registration\Service\RegistrationService;
|
use OCA\Registration\Service\RegistrationService;
|
||||||
use OCA\Registration\Util\CoreBridge;
|
|
||||||
use OCP\AppFramework\Http;
|
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
|
||||||
use OCP\Defaults;
|
use OCP\Defaults;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
|
|
@ -19,7 +15,6 @@ use OCP\IRequest;
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
use OCP\Security\ICrypto;
|
use OCP\Security\ICrypto;
|
||||||
use OCP\ISession;
|
use OCP\ISession;
|
||||||
use OCP\IUser;
|
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
|
|
@ -28,6 +23,7 @@ use \OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
|
||||||
use ChristophWurst\Nextcloud\Testing\DatabaseTransaction;
|
use ChristophWurst\Nextcloud\Testing\DatabaseTransaction;
|
||||||
use ChristophWurst\Nextcloud\Testing\TestCase;
|
use ChristophWurst\Nextcloud\Testing\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class RegistrationControllerTest
|
* class RegistrationControllerTest
|
||||||
*
|
*
|
||||||
|
|
@ -67,7 +63,7 @@ class RegisterControllerTest extends TestCase {
|
||||||
/** @var ICrypto */
|
/** @var ICrypto */
|
||||||
private $crypto;
|
private $crypto;
|
||||||
|
|
||||||
public function setUp (): void {
|
public function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->mailService = $this->createMock(MailService::class);
|
$this->mailService = $this->createMock(MailService::class);
|
||||||
$this->l10n = $this->createMock(IL10N::class);
|
$this->l10n = $this->createMock(IL10N::class);
|
||||||
|
|
@ -134,9 +130,9 @@ class RegisterControllerTest extends TestCase {
|
||||||
|
|
||||||
$ret = $this->controller->validateEmail($email);
|
$ret = $this->controller->validateEmail($email);
|
||||||
|
|
||||||
$expected = new TemplateResponse('registration', 'message', array('msg' =>
|
$expected = new TemplateResponse('registration', 'message', ['msg' =>
|
||||||
$this->l10n->t('Verification email successfully sent.')
|
$this->l10n->t('Verification email successfully sent.')
|
||||||
), 'guest');
|
], 'guest');
|
||||||
|
|
||||||
|
|
||||||
$this->assertEquals($expected, $ret, print_r($ret, true));
|
$this->assertEquals($expected, $ret, print_r($ret, true));
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,6 @@ use OCA\Registration\Db\Registration;
|
||||||
use OCA\Registration\Db\RegistrationMapper;
|
use OCA\Registration\Db\RegistrationMapper;
|
||||||
use OCA\Registration\Service\MailService;
|
use OCA\Registration\Service\MailService;
|
||||||
use OCA\Registration\Service\RegistrationService;
|
use OCA\Registration\Service\RegistrationService;
|
||||||
use OCA\Registration\Util\CoreBridge;
|
|
||||||
use OCP\AppFramework\Http;
|
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
|
||||||
use OCP\Defaults;
|
use OCP\Defaults;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
|
|
@ -26,6 +23,7 @@ use OCP\IUserSession;
|
||||||
|
|
||||||
use ChristophWurst\Nextcloud\Testing\DatabaseTransaction;
|
use ChristophWurst\Nextcloud\Testing\DatabaseTransaction;
|
||||||
use ChristophWurst\Nextcloud\Testing\TestCase;
|
use ChristophWurst\Nextcloud\Testing\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class RegistrationServiceTest
|
* class RegistrationServiceTest
|
||||||
*
|
*
|
||||||
|
|
@ -65,7 +63,7 @@ class RegistrationServiceTest extends TestCase {
|
||||||
/** @var ICrypto */
|
/** @var ICrypto */
|
||||||
private $crypto;
|
private $crypto;
|
||||||
|
|
||||||
public function setUp (): void {
|
public function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->mailService = $this->createMock(MailService::class);
|
$this->mailService = $this->createMock(MailService::class);
|
||||||
$this->l10n = $this->createMock(IL10N::class);
|
$this->l10n = $this->createMock(IL10N::class);
|
||||||
|
|
@ -202,7 +200,7 @@ class RegistrationServiceTest extends TestCase {
|
||||||
|
|
||||||
$this->config->expects($this->atLeastOnce())
|
$this->config->expects($this->atLeastOnce())
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->will($this->returnCallback(array($this, 'settingsCallback1')));
|
->will($this->returnCallback([$this, 'settingsCallback1']));
|
||||||
|
|
||||||
|
|
||||||
$form_input_username = 'alice1';
|
$form_input_username = 'alice1';
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class ApiControllerTest extends TestCase {
|
||||||
/** @var ApiController */
|
/** @var ApiController */
|
||||||
private $controller;
|
private $controller;
|
||||||
|
|
||||||
public function setUp (): void {
|
public function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->request = $this->createMock(IRequest::class);
|
$this->request = $this->createMock(IRequest::class);
|
||||||
$this->registrationService = $this->createMock(RegistrationService::class);
|
$this->registrationService = $this->createMock(RegistrationService::class);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue