-
@@ -33,6 +74,11 @@
import Card from 'src/components/UIComponents/Cards/Card.vue'
export default {
+ mounted() {
+ this.axios.get('/settings').then(response => {
+ this.settings = response.data;
+ })
+ },
components: {
Card,
PCheckbox
@@ -43,8 +89,18 @@
_username: '',
_password: '',
},
+ register: {
+ username: '',
+ password: '',
+ passwordConfirm: '',
+ email: ''
+ },
rememberMe: false,
- authFailed: false
+ authFailed: false,
+ settings: {
+ registrationEnabled: false
+ },
+ showRegistration: false
}
},
methods: {
@@ -64,6 +120,25 @@
};
this.$notify(
+ {
+ component: notification,
+ icon: 'fa fa-exclamation-triangle',
+ horizontalAlign: 'right',
+ verticalAlign: 'top',
+ type: 'danger'
+ });
+ }
+ })
+ },
+ onRegister: function(e) {
+ e.preventDefault();
+
+ if (this.register.password !== this.register.passwordConfirm) {
+ const notification = {
+ template: `
Passwords are not equal`
+ };
+
+ this.$notify(
{
component: notification,
icon: 'fa fa-exclamation-triangle',
@@ -71,8 +146,39 @@
verticalAlign: 'top',
type: 'danger'
});
- }
- })
+ } else {
+ this.axios.post('/register', this.register).then(response => {
+ const notification = {
+ template: `
Registration was successfully. You can login now`
+ };
+
+ this.$notify(
+ {
+ component: notification,
+ icon: 'fa fa-exclamation-triangle',
+ horizontalAlign: 'right',
+ verticalAlign: 'top',
+ type: 'success'
+ });
+ this.toggleRegistration();
+ }).catch(error => {
+ const notification = {
+ template: `
${error.response.data.message}`
+ };
+
+ this.$notify(
+ {
+ component: notification,
+ icon: 'fa fa-exclamation-triangle',
+ horizontalAlign: 'right',
+ verticalAlign: 'top',
+ type: 'danger'
+ });
+ })
+ }
+ },
+ toggleRegistration: function () {
+ this.showRegistration = !this.showRegistration;
}
}
}
diff --git a/src/Command/CronRunnerCommand.php b/src/Command/CronRunnerCommand.php
index 50889b7..d9fe541 100644
--- a/src/Command/CronRunnerCommand.php
+++ b/src/Command/CronRunnerCommand.php
@@ -63,7 +63,7 @@ class CronRunnerCommand extends Command implements ContainerAwareInterface
{
if ($this->connection->fetchColumn('SELECT 1 FROM queue')) {
$this->configGenerator->generate();
- system($this->container->getParameter('nginxRestartCommand'));
+ system($this->container->getParameter('nginxReloadCommand'));
$io = new SymfonyStyle($input, $output);
$io->success('Configs generated, rtmp has been reloaded');
diff --git a/src/Command/SetupCommand.php b/src/Command/SetupCommand.php
index 9e1cb3a..b75f5ca 100644
--- a/src/Command/SetupCommand.php
+++ b/src/Command/SetupCommand.php
@@ -48,22 +48,24 @@ class SetupCommand extends Command
$appHost = $io->ask('Please specify a http url where recast will be available', 'http://app.recast.in');
$nginxFolder = $io->ask('Please specify the nginx folder where nginx rtmp is installed', '/opt/nginx-rtmp/conf/');
$nginxReloadCommand = $io->ask('Please specify the command that should be executed to reload nginx rtmp', 'systemctl reload nginx-rtmp');
+ $registerEnabled = $io->ask('Should the registration enabled? (true / false)', 'true');
if (parse_url($appHost, PHP_URL_SCHEME) !== 'http') {
throw new \RuntimeException('URL must be http due nginx-rtmp limitations');
}
$envs = [];
+ $envs['APP_HOST'] = $appHost;
$envs['APP_ENV'] = 'prod';
$envs['APP_SECRET'] = $this->generateRandomString();
+ $envs['REGISTRATION_ENABLED'] = $registerEnabled;
$envs['MAILER_URL'] = 'null://localhost';
$envs['JWT_PRIVATE_KEY_PATH'] = 'config/jwt/private.pem';
$envs['JWT_PUBLIC_KEY_PATH'] = 'config/jwt/public.pem';
$envs['JWT_PASSPHRASE'] = 'a758fddfbc878122f8b37259b8ea14c3';
$envs['DATABASE_URL'] = sprintf('mysql://%s:%s@%s:%s/%s', $user, $password, $host, $hostPort, $dbName);
$envs['NGINX_CONFIG_DIR'] = $nginxFolder;
- $envs['APP_HOST'] = $appHost;
- $envs['NGINX_RESTART_COMMAND'] = $nginxReloadCommand;
+ $envs['NGINX_RELOAD_COMMAND'] = $nginxReloadCommand;
$stringEnv = [];
foreach ($envs as $env => $value) {
diff --git a/src/Controller/Index.php b/src/Controller/Index.php
index aef5db1..aa72bb8 100644
--- a/src/Controller/Index.php
+++ b/src/Controller/Index.php
@@ -1,20 +1,36 @@
+ */
class Index extends Controller
{
/**
* @Route(path="/", name="index")
* @author Soner Sayakci
*/
- public function index()
+ public function index(): Response
{
return $this->render('index.twig');
}
+
+ /**
+ * @Route(path="/api/settings")
+ * @author Soner Sayakci
+ */
+ public function settings(): JsonResponse
+ {
+ return new JsonResponse([
+ 'registrationEnabled' => XmlUtils::phpize($this->container->getParameter('registrationEnabled'))
+ ]);
+ }
}
\ No newline at end of file
diff --git a/src/Controller/Register.php b/src/Controller/Register.php
new file mode 100644
index 0000000..b1b7cba
--- /dev/null
+++ b/src/Controller/Register.php
@@ -0,0 +1,92 @@
+
+ */
+class Register extends Controller
+{
+ /**
+ * @var UserRepository
+ */
+ private $repository;
+
+ /**
+ * @var UserPasswordEncoderInterface
+ */
+ private $userPasswordEncoder;
+
+ /**
+ * Register constructor.
+ * @param UserRepository $repository
+ * @param UserPasswordEncoderInterface $userPasswordEncoder
+ * @author Soner Sayakci
+ */
+ public function __construct(UserRepository $repository, UserPasswordEncoderInterface $userPasswordEncoder)
+ {
+ $this->repository = $repository;
+ $this->userPasswordEncoder = $userPasswordEncoder;
+ }
+
+ /**
+ * @Route(path="/register")
+ * @author Soner Sayakci
+ * @param Request $request
+ * @return JsonResponse
+ */
+ public function index(Request $request): JsonResponse
+ {
+ if (!$this->isRegistrationEnabled()) {
+ return new JsonResponse(['message' => 'Registration is disabled'], 500);
+ }
+
+ $data = $request->request->all();
+
+ if ($this->repository->findOneBy(['username' => $data['username']])) {
+ return new JsonResponse(['message' => 'Username is already taken'], 500);
+ }
+
+ if ($this->repository->findOneBy(['email' => $data['email']])) {
+ return new JsonResponse(['message' => 'Email is already taken'], 500);
+ }
+
+
+ $user = new User();
+ $user->setUsername($data['username']);
+ $user->setPassword($this->userPasswordEncoder->encodePassword($user, $data['password']));
+ $user->setEmail($data['email']);
+
+ $manager = $this->get('doctrine.orm.default_entity_manager');
+
+ try {
+ $manager->persist($user);
+ $manager->flush();
+ } catch (ORMException $e) {
+ return new JsonResponse(['message' => $e->getMessage()], 500);
+ }
+
+ return new JsonResponse();
+ }
+
+ /**
+ * @return bool
+ * @author Soner Sayakci
+ */
+ private function isRegistrationEnabled(): bool
+ {
+ return XmlUtils::phpize($this->container->getParameter('registrationEnabled'));
+ }
+}
\ No newline at end of file
diff --git a/webpack.config.js b/webpack.config.js
deleted file mode 100644
index e36fa20..0000000
--- a/webpack.config.js
+++ /dev/null
@@ -1,24 +0,0 @@
-var Encore = require('@symfony/webpack-encore');
-
-Encore
- // the project directory where compiled assets will be stored
- .setOutputPath('public/build/')
- // the public path used by the web server to access the previous directory
- .setPublicPath('/build')
- .cleanupOutputBeforeBuild()
- .enableSourceMaps(!Encore.isProduction())
- // uncomment to create hashed filenames (e.g. app.abc123.css)
- // .enableVersioning(Encore.isProduction())
-
- // uncomment to define the assets of the project
- // .addEntry('js/app', './assets/js/app.js')
- // .addStyleEntry('css/app', './assets/css/app.scss')
-
- // uncomment if you use Sass/SCSS files
- // .enableSassLoader()
-
- // uncomment for legacy applications that require $/jQuery as a global variable
- // .autoProvidejQuery()
-;
-
-module.exports = Encore.getWebpackConfig();