forked from miguel456/rbrecruiter
Compare commits
4 Commits
analysis-a
...
master
Author | SHA1 | Date | |
---|---|---|---|
85c719c24d | |||
5df3f965ef | |||
4eb115d165 | |||
0433ce7693 |
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
@ -29,10 +10,13 @@ class Application extends Model
|
|||||||
|
|
||||||
'applicantUserID',
|
'applicantUserID',
|
||||||
'applicantFormResponseID',
|
'applicantFormResponseID',
|
||||||
'applicationStatus',
|
'applicationStatus'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\User', 'applicantUserID', 'id');
|
return $this->belongsTo('App\User', 'applicantUserID', 'id');
|
||||||
@ -53,6 +37,7 @@ class Application extends Model
|
|||||||
return $this->belongsToMany('App\Vote', 'votes_has_application');
|
return $this->belongsToMany('App\Vote', 'votes_has_application');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function comments()
|
public function comments()
|
||||||
{
|
{
|
||||||
return $this->hasMany('App\Comment', 'applicationID', 'id');
|
return $this->hasMany('App\Comment', 'applicationID', 'id');
|
||||||
@ -61,7 +46,8 @@ class Application extends Model
|
|||||||
public function setStatus($status)
|
public function setStatus($status)
|
||||||
{
|
{
|
||||||
return $this->update([
|
return $this->update([
|
||||||
'applicationStatus' => $status,
|
'applicationStatus' => $status
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
@ -32,7 +13,7 @@ class Appointment extends Model
|
|||||||
'appointmentStatus',
|
'appointmentStatus',
|
||||||
'appointmentLocation',
|
'appointmentLocation',
|
||||||
'meetingNotes',
|
'meetingNotes',
|
||||||
'userAccepted',
|
'userAccepted'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function application()
|
public function application()
|
||||||
@ -44,7 +25,7 @@ class Appointment extends Model
|
|||||||
public function setStatus($status)
|
public function setStatus($status)
|
||||||
{
|
{
|
||||||
$this->update([
|
$this->update([
|
||||||
'appointmentStatus' => $status,
|
'appointmentStatus' => $status
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
25
app/Ban.php
25
app/Ban.php
@ -1,46 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Ban extends Model
|
class Ban extends Model
|
||||||
{
|
{
|
||||||
|
|
||||||
public $fillable = [
|
public $fillable = [
|
||||||
|
|
||||||
'userID',
|
'userID',
|
||||||
'reason',
|
'reason',
|
||||||
'bannedUntil',
|
'bannedUntil',
|
||||||
'userAgent',
|
'userAgent',
|
||||||
'authorUserID',
|
'authorUserID'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public $dates = [
|
public $dates = [
|
||||||
'bannedUntil',
|
'bannedUntil'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\User', 'userID', 'id');
|
return $this->belongsTo('App\User', 'userID', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Comment extends Model
|
class Comment extends Model
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'authorID',
|
'authorID',
|
||||||
'applicationID',
|
'applicationID',
|
||||||
'text',
|
'text'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function application()
|
public function application()
|
||||||
@ -40,4 +22,5 @@ class Comment extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo('App\User', 'authorID', 'id');
|
return $this->belongsTo('App\User', 'authorID', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Application;
|
use App\Application;
|
||||||
@ -62,23 +43,28 @@ class CountVotes extends Command
|
|||||||
$eligibleApps = Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get();
|
$eligibleApps = Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get();
|
||||||
$pbar = $this->output->createProgressBar($eligibleApps->count());
|
$pbar = $this->output->createProgressBar($eligibleApps->count());
|
||||||
|
|
||||||
if ($eligibleApps->isEmpty()) {
|
if($eligibleApps->isEmpty())
|
||||||
|
{
|
||||||
$this->error('𐄂 There are no applications that need to be processed.');
|
$this->error('𐄂 There are no applications that need to be processed.');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($eligibleApps as $application) {
|
foreach ($eligibleApps as $application)
|
||||||
|
{
|
||||||
$votes = $application->votes;
|
$votes = $application->votes;
|
||||||
$voteCount = $application->votes->count();
|
$voteCount = $application->votes->count();
|
||||||
|
|
||||||
$positiveVotes = 0;
|
$positiveVotes = 0;
|
||||||
$negativeVotes = 0;
|
$negativeVotes = 0;
|
||||||
|
|
||||||
if ($voteCount > 5) {
|
if ($voteCount > 5)
|
||||||
|
{
|
||||||
$this->info('Counting votes for application ID ' . $application->id);
|
$this->info('Counting votes for application ID ' . $application->id);
|
||||||
foreach ($votes as $vote) {
|
foreach ($votes as $vote)
|
||||||
switch ($vote->allowedVoteType) {
|
{
|
||||||
|
switch ($vote->allowedVoteType)
|
||||||
|
{
|
||||||
case 'VOTE_APPROVE':
|
case 'VOTE_APPROVE':
|
||||||
$positiveVotes++;
|
$positiveVotes++;
|
||||||
break;
|
break;
|
||||||
@ -97,43 +83,54 @@ class CountVotes extends Command
|
|||||||
|
|
||||||
$this->table([
|
$this->table([
|
||||||
'% of approval votes',
|
'% of approval votes',
|
||||||
'% of denial votes',
|
'% of denial votes'
|
||||||
], [ // array of arrays, e.g. rows
|
], [ // array of arrays, e.g. rows
|
||||||
[
|
[
|
||||||
$positiveVotePercent.'%',
|
$positiveVotePercent . "%",
|
||||||
$negativeVotePercent.'%',
|
$negativeVotePercent . "%"
|
||||||
],
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($pollResult) {
|
if ($pollResult)
|
||||||
|
{
|
||||||
$this->info('✓ Dispatched promotion event for applicant ' . $application->user->name);
|
$this->info('✓ Dispatched promotion event for applicant ' . $application->user->name);
|
||||||
if (! $this->option('dryrun')) {
|
if (!$this->option('dryrun'))
|
||||||
|
{
|
||||||
$application->response->vacancy->vacancyCount -= 1;
|
$application->response->vacancy->vacancyCount -= 1;
|
||||||
$application->response->vacancy->save();
|
$application->response->vacancy->save();
|
||||||
|
|
||||||
event(new ApplicationApprovedEvent(Application::find($application->id)));
|
event(new ApplicationApprovedEvent(Application::find($application->id)));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$this->warn('Dry run: Event won\'t be dispatched');
|
$this->warn('Dry run: Event won\'t be dispatched');
|
||||||
}
|
}
|
||||||
|
|
||||||
$pbar->advance();
|
$pbar->advance();
|
||||||
} else {
|
|
||||||
if (! $this->option('dryrun')) {
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
if (!$this->option('dryrun'))
|
||||||
|
{
|
||||||
event(new ApplicationDeniedEvent(Application::find($application->id)));
|
event(new ApplicationDeniedEvent(Application::find($application->id)));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$this->warn('Dry run: Event won\'t be dispatched');
|
$this->warn('Dry run: Event won\'t be dispatched');
|
||||||
}
|
}
|
||||||
|
|
||||||
$pbar->advance();
|
$pbar->advance();
|
||||||
$this->error('𐄂 Applicant ' . $application->user->name . ' does not meet vote criteria (Majority)');
|
$this->error('𐄂 Applicant ' . $application->user->name . ' does not meet vote criteria (Majority)');
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$this->warn('Application ID'.$application->id.' did not have enough votes for processing (min 5)');
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->warn("Application ID" . $application->id . " did not have enough votes for processing (min 5)");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$pbar->finish();
|
$pbar->finish();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
@ -58,11 +39,14 @@ class Install extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$basePath = base_path();
|
$basePath = base_path();
|
||||||
if (Storage::disk('local')->missing('INSTALLED')) {
|
if (Storage::disk('local')->missing('INSTALLED'))
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
$this->info('[!! Welcome to Rasberry Teams !!]');
|
$this->info('[!! Welcome to Rasberry Teams !!]');
|
||||||
$this->info('>> Installing...');
|
$this->info('>> Installing...');
|
||||||
$this->call('down', [
|
$this->call('down', [
|
||||||
'--message' => 'Down for maintenance. We\'ll be right back!',
|
'--message' => 'Down for maintenance. We\'ll be right back!'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
copy($basePath . '/.env.example', $basePath . '/.env');
|
copy($basePath . '/.env.example', $basePath . '/.env');
|
||||||
@ -79,17 +63,22 @@ class Install extends Command
|
|||||||
exec('cd ' . $basePath . ' && npm install --silent', $npmBuildOut, $npmOut);
|
exec('cd ' . $basePath . ' && npm install --silent', $npmBuildOut, $npmOut);
|
||||||
exec('cd ' . $basePath . '&& npm run dev --silent', $npmBuildMessages, $npmBuildOut);
|
exec('cd ' . $basePath . '&& npm run dev --silent', $npmBuildMessages, $npmBuildOut);
|
||||||
|
|
||||||
if ($npmOut !== 0 && $npmBuildOut !== 0) {
|
|
||||||
|
if($npmOut !== 0 && $npmBuildOut !== 0)
|
||||||
|
{
|
||||||
$this->error('[!] One or more errors have ocurred whilst attempting to install dependencies.');
|
$this->error('[!] One or more errors have ocurred whilst attempting to install dependencies.');
|
||||||
$this->error('[!] It is recommended to run this command again, and report a bug if it keeps happening.');
|
$this->error('[!] It is recommended to run this command again, and report a bug if it keeps happening.');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$settings = [];
|
$settings = [];
|
||||||
|
|
||||||
$this->info('>> Configuring application - We\'re going to ask a few questions here!');
|
$this->info('>> Configuring application - We\'re going to ask a few questions here!');
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
$this->info('== Database Settings (1/6) ==');
|
$this->info('== Database Settings (1/6) ==');
|
||||||
|
|
||||||
$settings['DB_USERNAME'] = $this->ask('Database username');
|
$settings['DB_USERNAME'] = $this->ask('Database username');
|
||||||
@ -110,7 +99,7 @@ class Install extends Command
|
|||||||
$settings['MAIL_PASSWORD'] = $this->secret('SMTP Password (Input won\'t be seen)');
|
$settings['MAIL_PASSWORD'] = $this->secret('SMTP Password (Input won\'t be seen)');
|
||||||
$settings['MAIL_PORT'] = $this->ask('SMTP Server Port');
|
$settings['MAIL_PORT'] = $this->ask('SMTP Server Port');
|
||||||
$settings['MAIL_HOST'] = $this->ask('SMTP Server Hostname');
|
$settings['MAIL_HOST'] = $this->ask('SMTP Server Hostname');
|
||||||
$settings['MAIL_FROM'] = $this->ask('E-mail address to send from: ');
|
$settings['MAIL_FROM_ADDRESS'] = $this->ask('E-mail address to send from');
|
||||||
|
|
||||||
$this->info('== Notification Settings (5/6) (Slack) ==');
|
$this->info('== Notification Settings (5/6) (Slack) ==');
|
||||||
$settings['SLACK_INTEGRATION_WEBHOOK'] = $this->ask('Integration webhook URL');
|
$settings['SLACK_INTEGRATION_WEBHOOK'] = $this->ask('Integration webhook URL');
|
||||||
@ -119,12 +108,15 @@ class Install extends Command
|
|||||||
$settings['APP_URL'] = $this->ask('Application\'s URL (ex. https://where.you.installed.theapp.com): ');
|
$settings['APP_URL'] = $this->ask('Application\'s URL (ex. https://where.you.installed.theapp.com): ');
|
||||||
$settings['APP_LOGO'] = $this->ask('App logo (Link to an image): ');
|
$settings['APP_LOGO'] = $this->ask('App logo (Link to an image): ');
|
||||||
$settings['APP_SITEHOMEPAGE'] = $this->ask('Site homepage (appears in the main header): ');
|
$settings['APP_SITEHOMEPAGE'] = $this->ask('Site homepage (appears in the main header): ');
|
||||||
|
|
||||||
|
|
||||||
} while(!$this->confirm('Are you sure you want to save these settings? You can always go back and try again.'));
|
} while(!$this->confirm('Are you sure you want to save these settings? You can always go back and try again.'));
|
||||||
|
|
||||||
foreach ($settings as $keyname => $value) {
|
foreach($settings as $keyname => $value)
|
||||||
|
{
|
||||||
$this->call('environment:modify', [
|
$this->call('environment:modify', [
|
||||||
'key' => $keyname,
|
'key' => $keyname,
|
||||||
'value' => $value,
|
'value' => $value
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +131,10 @@ class Install extends Command
|
|||||||
|
|
||||||
$this->call('up');
|
$this->call('up');
|
||||||
$this->info('>> All done! Visit ' . $basePath . ' to start using your brand new installation of Raspberry Teams!');
|
$this->info('>> All done! Visit ' . $basePath . ' to start using your brand new installation of Raspberry Teams!');
|
||||||
} else {
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$this->error('[!] The application is already installed!');
|
$this->error('[!] The application is already installed!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use GeoSot\EnvEditor\Facades\EnvEditor;
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use GeoSot\EnvEditor\Facades\EnvEditor;
|
||||||
|
|
||||||
class SetEnv extends Command
|
class SetEnv extends Command
|
||||||
{
|
{
|
||||||
@ -60,11 +41,15 @@ class SetEnv extends Command
|
|||||||
$key = $this->argument('key');
|
$key = $this->argument('key');
|
||||||
$value = $this->argument('value');
|
$value = $this->argument('value');
|
||||||
|
|
||||||
if (file_exists($path)) {
|
|
||||||
EnvEditor::editKey($key, $value);
|
|
||||||
} else {
|
|
||||||
$this->error('Cannot update a file that doesn\'t exist! Please create .env first.');
|
|
||||||
|
|
||||||
|
|
||||||
|
if (file_exists($path))
|
||||||
|
{
|
||||||
|
EnvEditor::editKey($key, $value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error('Cannot update a file that doesn\'t exist! Please create .env first.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Console;
|
namespace App\Console;
|
||||||
|
|
||||||
use App\Jobs\CleanBans;
|
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
use App\Jobs\CleanBans;
|
||||||
|
|
||||||
class Kernel extends ConsoleKernel
|
class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\CustomFacades;
|
namespace App\CustomFacades;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
@ -26,6 +7,7 @@ use Illuminate\Support\Facades\Http;
|
|||||||
|
|
||||||
class IP
|
class IP
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up information on a specified IP address. Caches results automatically.
|
* Looks up information on a specified IP address. Caches results automatically.
|
||||||
* @param string $IP IP address to lookup
|
* @param string $IP IP address to lookup
|
||||||
@ -33,18 +15,23 @@ class IP
|
|||||||
*/
|
*/
|
||||||
public function lookup(string $IP): object
|
public function lookup(string $IP): object
|
||||||
{
|
{
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'apiKey' => config('general.keys.ipapi.apikey'),
|
'apiKey' => config('general.keys.ipapi.apikey'),
|
||||||
'ip' => $IP,
|
'ip' => $IP
|
||||||
];
|
];
|
||||||
|
|
||||||
// TODO: Maybe unwrap this? Methods are chained here
|
// TODO: Maybe unwrap this? Methods are chained here
|
||||||
|
|
||||||
return json_decode(Cache::remember($IP, 3600, function () use ($IP) {
|
return json_decode(Cache::remember($IP, 3600, function() use ($IP)
|
||||||
|
{
|
||||||
return Http::get(config('general.urls.ipapi.ipcheck'), [
|
return Http::get(config('general.urls.ipapi.ipcheck'), [
|
||||||
'apiKey' => config('general.keys.ipapi.apikey'),
|
'apiKey' => config('general.keys.ipapi.apikey'),
|
||||||
'ip' => $IP,
|
'ip' => $IP
|
||||||
])->body();
|
])->body();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Application;
|
use App\Application;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
@ -41,4 +26,6 @@ class ApplicationApprovedEvent
|
|||||||
{
|
{
|
||||||
$this->application = $application;
|
$this->application = $application;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Application;
|
use App\Application;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
@ -41,4 +26,5 @@ class ApplicationDeniedEvent
|
|||||||
{
|
{
|
||||||
$this->application = $application;
|
$this->application = $application;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
use Illuminate\Broadcasting\PrivateChannel;
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
@ -1,36 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Ban;
|
use Illuminate\Broadcasting\Channel;
|
||||||
use App\User;
|
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
use App\Ban;
|
||||||
|
|
||||||
class UserBannedEvent
|
class UserBannedEvent
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
|
||||||
public $user;
|
public $user;
|
||||||
|
|
||||||
public $ban;
|
public $ban;
|
||||||
@ -45,4 +32,5 @@ class UserBannedEvent
|
|||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->ban = $ban;
|
$this->ban = $ban;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
@ -1,32 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Facades;
|
namespace App\Facades;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Facade;
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
class ContextAwareValidation extends Facade
|
class ContextAwareValidation extends Facade
|
||||||
{
|
{
|
||||||
|
|
||||||
protected static function getFacadeAccessor()
|
protected static function getFacadeAccessor()
|
||||||
{
|
{
|
||||||
return 'contextAwareValidator';
|
return 'contextAwareValidator';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Facades;
|
namespace App\Facades;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Facade;
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
@ -1,27 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Facades;
|
namespace App\Facades;
|
||||||
|
use \Illuminate\Support\Facades\Facade;
|
||||||
use Illuminate\Support\Facades\Facade;
|
|
||||||
|
|
||||||
class Options extends Facade
|
class Options extends Facade
|
||||||
{
|
{
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Facades;
|
namespace App\Facades;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Facade;
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
21
app/Form.php
21
app/Form.php
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
@ -29,7 +10,7 @@ class Form extends Model
|
|||||||
|
|
||||||
'formName',
|
'formName',
|
||||||
'formStructure',
|
'formStructure',
|
||||||
'formStatus',
|
'formStatus'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1,31 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class ContextAwareValidator
|
class ContextAwareValidator
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The excludedNames array will make the validator ignore any of these names when including names into the rules.
|
* The excludedNames array will make the validator ignore any of these names when including names into the rules.
|
||||||
* @var array
|
* @var array
|
||||||
@ -33,9 +15,10 @@ class ContextAwareValidator
|
|||||||
private $excludedNames = [
|
private $excludedNames = [
|
||||||
'_token',
|
'_token',
|
||||||
'_method',
|
'_method',
|
||||||
'formName',
|
'formName'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility wrapper for json_encode.
|
* Utility wrapper for json_encode.
|
||||||
*
|
*
|
||||||
@ -70,19 +53,24 @@ class ContextAwareValidator
|
|||||||
$formStructure = [];
|
$formStructure = [];
|
||||||
$validator = [];
|
$validator = [];
|
||||||
|
|
||||||
if ($includeFormName) {
|
if ($includeFormName)
|
||||||
|
{
|
||||||
$validator['formName'] = 'required|string|max:100';
|
$validator['formName'] = 'required|string|max:100';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($fields as $fieldName => $field) {
|
foreach ($fields as $fieldName => $field)
|
||||||
if (! in_array($fieldName, $this->excludedNames)) {
|
{
|
||||||
$validator[$fieldName.'.0'] = 'required|string';
|
if(!in_array($fieldName, $this->excludedNames))
|
||||||
$validator[$fieldName.'.1'] = 'required|string';
|
{
|
||||||
|
$validator[$fieldName . ".0"] = 'required|string';
|
||||||
|
$validator[$fieldName . ".1"] = 'required|string';
|
||||||
|
|
||||||
if ($generateStructure) {
|
if ($generateStructure)
|
||||||
|
{
|
||||||
$formStructure['fields'][$fieldName]['title'] = $field[0];
|
$formStructure['fields'][$fieldName]['title'] = $field[0];
|
||||||
$formStructure['fields'][$fieldName]['type'] = $field[1];
|
$formStructure['fields'][$fieldName]['type'] = $field[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,9 +79,11 @@ class ContextAwareValidator
|
|||||||
return ($generateStructure) ?
|
return ($generateStructure) ?
|
||||||
collect([
|
collect([
|
||||||
'validator' => $validatorInstance,
|
'validator' => $validatorInstance,
|
||||||
'structure' => $this->encode($formStructure),
|
'structure' => $this->encode($formStructure)
|
||||||
])
|
])
|
||||||
: $validatorInstance;
|
: $validatorInstance;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,18 +100,23 @@ class ContextAwareValidator
|
|||||||
*/
|
*/
|
||||||
public function getResponseValidator(array $fields, array $formStructure = [], bool $generateResponseStructure = true)
|
public function getResponseValidator(array $fields, array $formStructure = [], bool $generateResponseStructure = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
$responseStructure = [];
|
$responseStructure = [];
|
||||||
$validator = [];
|
$validator = [];
|
||||||
|
|
||||||
if (empty($formStructure) && $generateResponseStructure) {
|
if (empty($formStructure) && $generateResponseStructure)
|
||||||
|
{
|
||||||
throw new \InvalidArgumentException('Illegal combination of arguments supplied! Please check the method\'s documentation.');
|
throw new \InvalidArgumentException('Illegal combination of arguments supplied! Please check the method\'s documentation.');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($fields as $fieldName => $value) {
|
foreach($fields as $fieldName => $value)
|
||||||
if (! in_array($fieldName, $this->excludedNames)) {
|
{
|
||||||
|
if(!in_array($fieldName, $this->excludedNames))
|
||||||
|
{
|
||||||
$validator[$fieldName] = 'required|string';
|
$validator[$fieldName] = 'required|string';
|
||||||
|
|
||||||
if ($generateResponseStructure) {
|
if ($generateResponseStructure)
|
||||||
|
{
|
||||||
$responseStructure['responses'][$fieldName]['type'] = $formStructure['fields'][$fieldName]['type'] ?? 'Unavailable';
|
$responseStructure['responses'][$fieldName]['type'] = $formStructure['fields'][$fieldName]['type'] ?? 'Unavailable';
|
||||||
$responseStructure['responses'][$fieldName]['title'] = $formStructure['fields'][$fieldName]['title'];
|
$responseStructure['responses'][$fieldName]['title'] = $formStructure['fields'][$fieldName]['title'];
|
||||||
$responseStructure['responses'][$fieldName]['response'] = $value;
|
$responseStructure['responses'][$fieldName]['response'] = $value;
|
||||||
@ -134,8 +129,10 @@ class ContextAwareValidator
|
|||||||
return ($generateResponseStructure) ?
|
return ($generateResponseStructure) ?
|
||||||
collect([
|
collect([
|
||||||
'validator' => $validatorInstance,
|
'validator' => $validatorInstance,
|
||||||
'responseStructure' => $this->encode($responseStructure),
|
'responseStructure' => $this->encode($responseStructure)
|
||||||
])
|
])
|
||||||
: $validatorInstance;
|
: $validatorInstance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
@ -27,16 +9,18 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
class Options
|
class Options
|
||||||
{
|
{
|
||||||
|
|
||||||
public function getOption(string $option): string
|
public function getOption(string $option): string
|
||||||
{
|
{
|
||||||
$value = Cache::get($option);
|
$value = Cache::get($option);
|
||||||
|
|
||||||
if (is_null($value)) {
|
if (is_null($value))
|
||||||
|
{
|
||||||
Log::debug('Option ' . $option . 'not found in cache, refreshing from database');
|
Log::debug('Option ' . $option . 'not found in cache, refreshing from database');
|
||||||
$value = Option::where('option_name', $option)->first();
|
$value = Option::where('option_name', $option)->first();
|
||||||
if (is_null($value)) {
|
if (is_null($value))
|
||||||
throw new \Exception('This option does not exist.');
|
throw new \Exception('This option does not exist.');
|
||||||
}
|
|
||||||
Cache::put($option, $value);
|
Cache::put($option, $value);
|
||||||
Cache::put($option . '_desc', 'Undefined description');
|
Cache::put($option . '_desc', 'Undefined description');
|
||||||
}
|
}
|
||||||
@ -49,7 +33,7 @@ class Options
|
|||||||
Option::create([
|
Option::create([
|
||||||
'option_name' => $option,
|
'option_name' => $option,
|
||||||
'option_value' => $value,
|
'option_value' => $value,
|
||||||
'friendly_name' => $description,
|
'friendly_name' => $description
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Cache::put($option, $value, now()->addDay());
|
Cache::put($option, $value, now()->addDay());
|
||||||
@ -64,7 +48,7 @@ class Options
|
|||||||
// putMany is overkill here
|
// putMany is overkill here
|
||||||
return [
|
return [
|
||||||
Cache::pull($option),
|
Cache::pull($option),
|
||||||
Cache::pull($option.'_desc'),
|
Cache::pull($option . '_desc')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,13 +56,14 @@ class Options
|
|||||||
{
|
{
|
||||||
$dbOption = Option::where('option_name', $option);
|
$dbOption = Option::where('option_name', $option);
|
||||||
|
|
||||||
if ($dbOption->first()) {
|
if ($dbOption->first())
|
||||||
|
{
|
||||||
$dbOptionInstance = Option::find($dbOption->first()->id);
|
$dbOptionInstance = Option::find($dbOption->first()->id);
|
||||||
Cache::forget($option);
|
Cache::forget($option);
|
||||||
|
|
||||||
Log::debug('Changing db configuration option', [
|
Log::debug('Changing db configuration option', [
|
||||||
'old_value' => $dbOptionInstance->option_value,
|
'old_value' => $dbOptionInstance->option_value,
|
||||||
'new_value' => $newValue,
|
'new_value' => $newValue
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$dbOptionInstance->option_value = $newValue;
|
$dbOptionInstance->option_value = $newValue;
|
||||||
@ -86,15 +71,18 @@ class Options
|
|||||||
|
|
||||||
Log::debug('New db configuration option saved',
|
Log::debug('New db configuration option saved',
|
||||||
[
|
[
|
||||||
'option' => $dbOptionInstance->option_value,
|
'option' => $dbOptionInstance->option_value
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Cache::put('option_name', $newValue, now()->addDay());
|
Cache::put('option_name', $newValue, now()->addDay());
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
throw new \Exception('This option does not exist.');
|
throw new \Exception('This option does not exist.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function optionExists(string $option): bool
|
public function optionExists(string $option): bool
|
||||||
{
|
{
|
||||||
$dbOption = Option::where('option_name', $option)->first();
|
$dbOption = Option::where('option_name', $option)->first();
|
||||||
@ -102,4 +90,5 @@ class Options
|
|||||||
|
|
||||||
return !is_null($dbOption) || !is_null($locallyCachedOption);
|
return !is_null($dbOption) || !is_null($locallyCachedOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,46 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Application;
|
use App\Application;
|
||||||
use App\Events\ApplicationDeniedEvent;
|
|
||||||
use App\Notifications\ApplicationMoved;
|
|
||||||
use App\Notifications\NewApplicant;
|
|
||||||
use App\Response;
|
use App\Response;
|
||||||
use App\User;
|
|
||||||
use App\Vacancy;
|
use App\Vacancy;
|
||||||
use ContextAwareValidator;
|
use App\User;
|
||||||
|
|
||||||
|
use App\Events\ApplicationDeniedEvent;
|
||||||
|
use App\Notifications\NewApplicant;
|
||||||
|
use App\Notifications\ApplicationMoved;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
use ContextAwareValidator;
|
||||||
|
|
||||||
class ApplicationController extends Controller
|
class ApplicationController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
private function canVote($votes)
|
private function canVote($votes)
|
||||||
{
|
{
|
||||||
$allvotes = collect([]);
|
$allvotes = collect([]);
|
||||||
|
|
||||||
foreach ($votes as $vote) {
|
foreach ($votes as $vote)
|
||||||
if ($vote->userID == Auth::user()->id) {
|
{
|
||||||
|
if ($vote->userID == Auth::user()->id)
|
||||||
|
{
|
||||||
$allvotes->push($vote);
|
$allvotes->push($vote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,17 +38,22 @@ class ApplicationController extends Controller
|
|||||||
return ($allvotes->count() == 1) ? false : true;
|
return ($allvotes->count() == 1) ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function showUserApps()
|
public function showUserApps()
|
||||||
{
|
{
|
||||||
|
|
||||||
return view('dashboard.user.applications')
|
return view('dashboard.user.applications')
|
||||||
->with('applications', Auth::user()->applications);
|
->with('applications', Auth::user()->applications);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function showUserApp(Request $request, Application $application)
|
public function showUserApp(Request $request, Application $application)
|
||||||
{
|
{
|
||||||
$this->authorize('view', $application);
|
$this->authorize('view', $application);
|
||||||
|
|
||||||
if (! is_null($application)) {
|
if (!is_null($application))
|
||||||
|
{
|
||||||
return view('dashboard.user.viewapp')
|
return view('dashboard.user.viewapp')
|
||||||
->with(
|
->with(
|
||||||
[
|
[
|
||||||
@ -67,16 +62,20 @@ class ApplicationController extends Controller
|
|||||||
'structuredResponses' => json_decode($application->response->responseData, true),
|
'structuredResponses' => json_decode($application->response->responseData, true),
|
||||||
'formStructure' => $application->response->form,
|
'formStructure' => $application->response->form,
|
||||||
'vacancy' => $application->response->vacancy,
|
'vacancy' => $application->response->vacancy,
|
||||||
'canVote' => $this->canVote($application->votes),
|
'canVote' => $this->canVote($application->votes)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'The application you requested could not be found.');
|
$request->session()->flash('error', 'The application you requested could not be found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function showAllApps()
|
public function showAllApps()
|
||||||
{
|
{
|
||||||
$this->authorize('viewAny', Application::class);
|
$this->authorize('viewAny', Application::class);
|
||||||
@ -85,6 +84,7 @@ class ApplicationController extends Controller
|
|||||||
->with('applications', Application::paginate(6));
|
->with('applications', Application::paginate(6));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function showAllPendingApps()
|
public function showAllPendingApps()
|
||||||
{
|
{
|
||||||
$this->authorize('viewAny', Application::class);
|
$this->authorize('viewAny', Application::class);
|
||||||
@ -93,6 +93,7 @@ class ApplicationController extends Controller
|
|||||||
->with('applications', Application::where('applicationStatus', 'STAGE_SUBMITTED')->get());
|
->with('applications', Application::where('applicationStatus', 'STAGE_SUBMITTED')->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function showPendingInterview()
|
public function showPendingInterview()
|
||||||
{
|
{
|
||||||
$this->authorize('viewAny', Application::class);
|
$this->authorize('viewAny', Application::class);
|
||||||
@ -102,12 +103,16 @@ class ApplicationController extends Controller
|
|||||||
$pendingInterviews = collect([]);
|
$pendingInterviews = collect([]);
|
||||||
$upcomingInterviews = collect([]);
|
$upcomingInterviews = collect([]);
|
||||||
|
|
||||||
foreach ($applications as $application) {
|
|
||||||
if (! is_null($application->appointment) && $application->appointment->appointmentStatus == 'CONCLUDED') {
|
foreach ($applications as $application)
|
||||||
|
{
|
||||||
|
if (!is_null($application->appointment) && $application->appointment->appointmentStatus == 'CONCLUDED')
|
||||||
|
{
|
||||||
$count =+ 1;
|
$count =+ 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($application->applicationStatus) {
|
switch ($application->applicationStatus)
|
||||||
|
{
|
||||||
case 'STAGE_INTERVIEW':
|
case 'STAGE_INTERVIEW':
|
||||||
$upcomingInterviews->push($application);
|
$upcomingInterviews->push($application);
|
||||||
|
|
||||||
@ -118,24 +123,29 @@ class ApplicationController extends Controller
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('dashboard.appmanagement.interview')
|
return view('dashboard.appmanagement.interview')
|
||||||
->with([
|
->with([
|
||||||
'finishedCount' => $count,
|
'finishedCount' => $count,
|
||||||
'applications' => $pendingInterviews,
|
'applications' => $pendingInterviews,
|
||||||
'upcomingApplications' => $upcomingInterviews,
|
'upcomingApplications' => $upcomingInterviews
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function showPeerReview()
|
public function showPeerReview()
|
||||||
{
|
{
|
||||||
$this->authorize('viewAny', Application::class);
|
$this->authorize('viewAny', Application::class);
|
||||||
|
|
||||||
return view('dashboard.appmanagement.peerreview')
|
return view('dashboard.appmanagement.peerreview')
|
||||||
->with('applications', Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get());
|
->with('applications', Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function renderApplicationForm(Request $request, $vacancySlug)
|
public function renderApplicationForm(Request $request, $vacancySlug)
|
||||||
{
|
{
|
||||||
// FIXME: Get rid of references to first(), this is a wonky query
|
// FIXME: Get rid of references to first(), this is a wonky query
|
||||||
@ -143,27 +153,36 @@ class ApplicationController extends Controller
|
|||||||
|
|
||||||
$firstVacancy = $vacancyWithForm->first();
|
$firstVacancy = $vacancyWithForm->first();
|
||||||
|
|
||||||
if (! $vacancyWithForm->isEmpty() && $firstVacancy->vacancyCount !== 0 && $firstVacancy->vacancyStatus == 'OPEN') {
|
if (!$vacancyWithForm->isEmpty() && $firstVacancy->vacancyCount !== 0 && $firstVacancy->vacancyStatus == 'OPEN')
|
||||||
|
{
|
||||||
|
|
||||||
return view('dashboard.application-rendering.apply')
|
return view('dashboard.application-rendering.apply')
|
||||||
->with([
|
->with([
|
||||||
|
|
||||||
'vacancy' => $vacancyWithForm->first(),
|
'vacancy' => $vacancyWithForm->first(),
|
||||||
'preprocessedForm' => json_decode($vacancyWithForm->first()->forms->formStructure, true),
|
'preprocessedForm' => json_decode($vacancyWithForm->first()->forms->formStructure, true)
|
||||||
|
|
||||||
]);
|
]);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
abort(404, 'The application you\'re looking for could not be found or it is currently unavailable.');
|
abort(404, 'The application you\'re looking for could not be found or it is currently unavailable.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function saveApplicationAnswers(Request $request, $vacancySlug)
|
public function saveApplicationAnswers(Request $request, $vacancySlug)
|
||||||
{
|
{
|
||||||
$vacancy = Vacancy::with('forms')->where('vacancySlug', $vacancySlug)->get();
|
$vacancy = Vacancy::with('forms')->where('vacancySlug', $vacancySlug)->get();
|
||||||
|
|
||||||
if ($vacancy->first()->vacancyCount == 0 || $vacancy->first()->vacancyStatus !== 'OPEN') {
|
if ($vacancy->first()->vacancyCount == 0 || $vacancy->first()->vacancyStatus !== 'OPEN')
|
||||||
$request->session()->flash('error', 'This application is unavailable.');
|
{
|
||||||
|
|
||||||
|
$request->session()->flash('error', 'This application is unavailable.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info('Processing new application!');
|
Log::info('Processing new application!');
|
||||||
@ -173,11 +192,12 @@ class ApplicationController extends Controller
|
|||||||
|
|
||||||
Log::info('Built response & validator structure!');
|
Log::info('Built response & validator structure!');
|
||||||
|
|
||||||
if (! $responseValidation->get('validator')->fails()) {
|
if (!$responseValidation->get('validator')->fails())
|
||||||
|
{
|
||||||
$response = Response::create([
|
$response = Response::create([
|
||||||
'responseFormID' => $vacancy->first()->forms->id,
|
'responseFormID' => $vacancy->first()->forms->id,
|
||||||
'associatedVacancyID' => $vacancy->first()->id, // Since a form can be used by multiple vacancies, we can only know which specific vacancy this response ties to by using a vacancy ID
|
'associatedVacancyID' => $vacancy->first()->id, // Since a form can be used by multiple vacancies, we can only know which specific vacancy this response ties to by using a vacancy ID
|
||||||
'responseData' => $responseValidation->get('responseStructure'),
|
'responseData' => $responseValidation->get('responseStructure')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Log::info('Registered form response for user ' . Auth::user()->name . ' for vacancy ' . $vacancy->first()->vacancyName);
|
Log::info('Registered form response for user ' . Auth::user()->name . ' for vacancy ' . $vacancy->first()->vacancyName);
|
||||||
@ -190,18 +210,22 @@ class ApplicationController extends Controller
|
|||||||
|
|
||||||
Log::info('Submitted application for user ' . Auth::user()->name . ' with response ID' . $response->id);
|
Log::info('Submitted application for user ' . Auth::user()->name . ' with response ID' . $response->id);
|
||||||
|
|
||||||
foreach (User::all() as $user) {
|
foreach(User::all() as $user)
|
||||||
if ($user->hasRole('admin')) {
|
{
|
||||||
|
if ($user->hasRole('admin'))
|
||||||
|
{
|
||||||
$user->notify((new NewApplicant($application, $vacancy->first()))->delay(now()->addSeconds(10)));
|
$user->notify((new NewApplicant($application, $vacancy->first()))->delay(now()->addSeconds(10)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->session()->flash('success', 'Thank you for your application! It will be reviewed as soon as possible.');
|
$request->session()->flash('success', 'Thank you for your application! It will be reviewed as soon as possible.');
|
||||||
|
|
||||||
return redirect()->to(route('showUserApps'));
|
return redirect()->to(route('showUserApps'));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Log::warning('Application form for ' . Auth::user()->name . ' contained errors, resetting!');
|
Log::warning('Application form for ' . Auth::user()->name . ' contained errors, resetting!');
|
||||||
$request->session()->flash('error', 'There are one or more errors in your application. Please make sure none of your fields are empty, since they are all required.');
|
$request->session()->flash('error', 'There are one or more errors in your application. Please make sure none of your fields are empty, since they are all required.');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
@ -211,7 +235,8 @@ class ApplicationController extends Controller
|
|||||||
{
|
{
|
||||||
$this->authorize('update', Application::class);
|
$this->authorize('update', Application::class);
|
||||||
|
|
||||||
switch ($newStatus) {
|
switch ($newStatus)
|
||||||
|
{
|
||||||
case 'deny':
|
case 'deny':
|
||||||
|
|
||||||
event(new ApplicationDeniedEvent($application));
|
event(new ApplicationDeniedEvent($application));
|
||||||
@ -234,11 +259,13 @@ class ApplicationController extends Controller
|
|||||||
|
|
||||||
public function delete(Request $request, Application $application)
|
public function delete(Request $request, Application $application)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('delete', $application);
|
$this->authorize('delete', $application);
|
||||||
$application->delete(); // observers will run, cleaning it up
|
$application->delete(); // observers will run, cleaning it up
|
||||||
|
|
||||||
$request->session()->flash('success', 'Application deleted. Comments, appointments and responses have also been deleted.');
|
$request->session()->flash('success', 'Application deleted. Comments, appointments and responses have also been deleted.');
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Application;
|
use App\Application;
|
||||||
use App\Appointment;
|
|
||||||
use App\Http\Requests\SaveNotesRequest;
|
use App\Http\Requests\SaveNotesRequest;
|
||||||
use App\Notifications\ApplicationMoved;
|
|
||||||
use App\Notifications\AppointmentScheduled;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Appointment;
|
||||||
|
use App\Notifications\ApplicationMoved;
|
||||||
|
use App\Notifications\AppointmentScheduled;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@ -39,7 +20,7 @@ class AppointmentController extends Controller
|
|||||||
'DISCORD',
|
'DISCORD',
|
||||||
'SKYPE',
|
'SKYPE',
|
||||||
'MEET',
|
'MEET',
|
||||||
'TEAMSPEAK',
|
'TEAMSPEAK'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -56,14 +37,16 @@ class AppointmentController extends Controller
|
|||||||
]);
|
]);
|
||||||
$application->setStatus('STAGE_INTERVIEW_SCHEDULED');
|
$application->setStatus('STAGE_INTERVIEW_SCHEDULED');
|
||||||
|
|
||||||
|
|
||||||
Log::info('User ' . Auth::user()->name . ' has scheduled an appointment with ' . $application->user->name . ' for application ID' . $application->id, [
|
Log::info('User ' . Auth::user()->name . ' has scheduled an appointment with ' . $application->user->name . ' for application ID' . $application->id, [
|
||||||
'datetime' => $appointmentDate->toDateTimeString(),
|
'datetime' => $appointmentDate->toDateTimeString(),
|
||||||
'scheduled' => now(),
|
'scheduled' => now()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$application->user->notify(new AppointmentScheduled($appointment));
|
$application->user->notify(new AppointmentScheduled($appointment));
|
||||||
$request->session()->flash('success', 'Appointment successfully scheduled @ ' . $appointmentDate->toDateTimeString());
|
$request->session()->flash('success', 'Appointment successfully scheduled @ ' . $appointmentDate->toDateTimeString());
|
||||||
|
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +56,7 @@ class AppointmentController extends Controller
|
|||||||
|
|
||||||
$validStatuses = [
|
$validStatuses = [
|
||||||
'SCHEDULED',
|
'SCHEDULED',
|
||||||
'CONCLUDED',
|
'CONCLUDED'
|
||||||
];
|
];
|
||||||
|
|
||||||
// NOTE: This is a little confusing, refactor
|
// NOTE: This is a little confusing, refactor
|
||||||
@ -83,25 +66,29 @@ class AppointmentController extends Controller
|
|||||||
$application->setStatus('STAGE_PEERAPPROVAL');
|
$application->setStatus('STAGE_PEERAPPROVAL');
|
||||||
$application->user->notify(new ApplicationMoved());
|
$application->user->notify(new ApplicationMoved());
|
||||||
|
|
||||||
$request->session()->flash('success', 'Interview finished! Staff members can now vote on it.');
|
|
||||||
|
|
||||||
|
$request->session()->flash('success', 'Interview finished! Staff members can now vote on it.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
// also updates
|
// also updates
|
||||||
public function saveNotes(SaveNotesRequest $request, Application $application)
|
public function saveNotes(SaveNotesRequest $request, Application $application)
|
||||||
{
|
{
|
||||||
if (! is_null($application)) {
|
if (!is_null($application))
|
||||||
|
{
|
||||||
$application->load('appointment');
|
$application->load('appointment');
|
||||||
|
|
||||||
$application->appointment->meetingNotes = $request->noteText;
|
$application->appointment->meetingNotes = $request->noteText;
|
||||||
$application->appointment->save();
|
$application->appointment->save();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Meeting notes have been saved.');
|
$request->session()->flash('success', 'Meeting notes have been saved.');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'There\'s no appointment to save notes to!');
|
$request->session()->flash('error', 'There\'s no appointment to save notes to!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||||
|
|
||||||
class ConfirmPasswordController extends Controller
|
class ConfirmPasswordController extends Controller
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
@ -1,28 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\User;
|
use App\User;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@ -66,15 +48,22 @@ class LoginController extends Controller
|
|||||||
{
|
{
|
||||||
$user = User::where('email', $request->email)->first();
|
$user = User::where('email', $request->email)->first();
|
||||||
|
|
||||||
if ($user) {
|
if ($user)
|
||||||
|
{
|
||||||
$isBanned = $user->isBanned();
|
$isBanned = $user->isBanned();
|
||||||
if ($isBanned) {
|
if ($isBanned)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return $this->originalAttemptLogin($request);
|
return $this->originalAttemptLogin($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->originalAttemptLogin($request);
|
return $this->originalAttemptLogin($request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
use App\User;
|
use App\User;
|
||||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use function GuzzleHttp\Psr7\str;
|
||||||
|
|
||||||
class RegisterController extends Controller
|
class RegisterController extends Controller
|
||||||
{
|
{
|
||||||
@ -64,8 +47,10 @@ class RegisterController extends Controller
|
|||||||
{
|
{
|
||||||
$users = User::where('originalIP', \request()->ip())->get();
|
$users = User::where('originalIP', \request()->ip())->get();
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach($users as $user)
|
||||||
if ($user && $user->isBanned()) {
|
{
|
||||||
|
if ($user && $user->isBanned())
|
||||||
|
{
|
||||||
abort(403, 'You do not have permission to access this page.');
|
abort(403, 'You do not have permission to access this page.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +72,7 @@ class RegisterController extends Controller
|
|||||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||||
'password' => ['required', 'string', 'min:10', 'confirmed', 'regex:/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\x])(?=.*[!$#%]).*$/'],
|
'password' => ['required', 'string', 'min:10', 'confirmed', 'regex:/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\x])(?=.*[!$#%]).*$/'],
|
||||||
], [
|
], [
|
||||||
'uuid.required' => 'Please enter a valid (and Premium) Minecraft username! We do not support cracked users.',
|
'uuid.required' => 'Please enter a valid (and Premium) Minecraft username! We do not support cracked users.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,19 +84,19 @@ class RegisterController extends Controller
|
|||||||
*/
|
*/
|
||||||
protected function create(array $data)
|
protected function create(array $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'uuid' => $data['uuid'],
|
'uuid' => $data['uuid'],
|
||||||
'name' => $data['name'],
|
'name' => $data['name'],
|
||||||
'email' => $data['email'],
|
'email' => $data['email'],
|
||||||
'password' => Hash::make($data['password']),
|
'password' => Hash::make($data['password']),
|
||||||
'originalIP' => request()->ip(),
|
'originalIP' => request()->ip()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// It's not the registration controller's concern to create a profile for the user,
|
// It's not the registration controller's concern to create a profile for the user,
|
||||||
// so this code has been moved to it's respective observer, following the separation of concerns pattern.
|
// so this code has been moved to it's respective observer, following the separation of concerns pattern.
|
||||||
|
|
||||||
$user->assignRole('user');
|
$user->assignRole('user');
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||||
|
|
||||||
class ResetPasswordController extends Controller
|
class ResetPasswordController extends Controller
|
||||||
|
@ -1,26 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Traits\AuthenticatesTwoFactor;
|
use App\Traits\AuthenticatesTwoFactor;
|
||||||
|
|
||||||
@ -28,5 +10,7 @@ class TwofaController extends Controller
|
|||||||
{
|
{
|
||||||
use AuthenticatesTwoFactor;
|
use AuthenticatesTwoFactor;
|
||||||
|
|
||||||
|
|
||||||
protected $redirectTo = '/dashboard';
|
protected $redirectTo = '/dashboard';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||||
|
|
||||||
class VerificationController extends Controller
|
class VerificationController extends Controller
|
||||||
|
@ -1,48 +1,35 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Ban;
|
|
||||||
use App\Events\UserBannedEvent;
|
|
||||||
use App\Http\Requests\BanUserRequest;
|
|
||||||
use App\User;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use App\Ban;
|
||||||
|
use App\User;
|
||||||
|
use App\Events\UserBannedEvent;
|
||||||
|
use App\Http\Requests\BanUserRequest;
|
||||||
|
|
||||||
class BanController extends Controller
|
class BanController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function insert(BanUserRequest $request, User $user)
|
public function insert(BanUserRequest $request, User $user)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('create', [Ban::class, $user]);
|
$this->authorize('create', [Ban::class, $user]);
|
||||||
|
|
||||||
if (is_null($user->bans)) {
|
if (is_null($user->bans))
|
||||||
|
{
|
||||||
|
|
||||||
$reason = $request->reason;
|
$reason = $request->reason;
|
||||||
$duration = strtolower($request->durationOperator);
|
$duration = strtolower($request->durationOperator);
|
||||||
$durationOperand = $request->durationOperand;
|
$durationOperand = $request->durationOperand;
|
||||||
|
|
||||||
$expiryDate = now();
|
$expiryDate = now();
|
||||||
|
|
||||||
if (! empty($duration)) {
|
if (!empty($duration))
|
||||||
switch ($duration) {
|
{
|
||||||
|
switch($duration)
|
||||||
|
{
|
||||||
case 'days':
|
case 'days':
|
||||||
$expiryDate->addDays($durationOperand);
|
$expiryDate->addDays($durationOperand);
|
||||||
break;
|
break;
|
||||||
@ -59,7 +46,9 @@ class BanController extends Controller
|
|||||||
$expiryDate->addYears($durationOperand);
|
$expiryDate->addYears($durationOperand);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Essentially permanent
|
// Essentially permanent
|
||||||
$expiryDate->addYears(5);
|
$expiryDate->addYears(5);
|
||||||
}
|
}
|
||||||
@ -68,27 +57,35 @@ class BanController extends Controller
|
|||||||
'userID' => $user->id,
|
'userID' => $user->id,
|
||||||
'reason' => $reason,
|
'reason' => $reason,
|
||||||
'bannedUntil' => $expiryDate->format('Y-m-d H:i:s'),
|
'bannedUntil' => $expiryDate->format('Y-m-d H:i:s'),
|
||||||
'userAgent' => 'Unknown',
|
'userAgent' => "Unknown",
|
||||||
'authorUserID' => Auth::user()->id,
|
'authorUserID' => Auth::user()->id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
event(new UserBannedEvent($user, $ban));
|
event(new UserBannedEvent($user, $ban));
|
||||||
$request->session()->flash('success', 'User banned successfully! Ban ID: #' . $ban->id);
|
$request->session()->flash('success', 'User banned successfully! Ban ID: #' . $ban->id);
|
||||||
} else {
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'User already banned!');
|
$request->session()->flash('error', 'User already banned!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function delete(Request $request, User $user)
|
public function delete(Request $request, User $user)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('delete', $user->bans);
|
$this->authorize('delete', $user->bans);
|
||||||
|
|
||||||
if (! is_null($user->bans)) {
|
if (!is_null($user->bans))
|
||||||
|
{
|
||||||
$user->bans->delete();
|
$user->bans->delete();
|
||||||
$request->session()->flash('success', 'User unbanned successfully!');
|
$request->session()->flash('success', 'User unbanned successfully!');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'This user isn\'t banned!');
|
$request->session()->flash('error', 'This user isn\'t banned!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,34 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Application;
|
|
||||||
use App\Comment;
|
|
||||||
use App\Http\Requests\NewCommentRequest;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use App\Http\Requests\NewCommentRequest;
|
||||||
|
|
||||||
|
use App\Comment;
|
||||||
|
use App\Application;
|
||||||
|
use App\Notifications\NewComment;
|
||||||
|
use App\User;
|
||||||
|
|
||||||
class CommentController extends Controller
|
class CommentController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -41,16 +26,21 @@ class CommentController extends Controller
|
|||||||
$comment = Comment::create([
|
$comment = Comment::create([
|
||||||
'authorID' => Auth::user()->id,
|
'authorID' => Auth::user()->id,
|
||||||
'applicationID' => $application->id,
|
'applicationID' => $application->id,
|
||||||
'text' => $request->comment,
|
'text' => $request->comment
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($comment) {
|
if ($comment)
|
||||||
|
{
|
||||||
|
|
||||||
$request->session()->flash('success', 'Comment posted! (:');
|
$request->session()->flash('success', 'Comment posted! (:');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'Something went wrong while posting your comment!');
|
$request->session()->flash('error', 'Something went wrong while posting your comment!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(Request $request, Comment $comment)
|
public function delete(Request $request, Comment $comment)
|
||||||
@ -61,5 +51,7 @@ class CommentController extends Controller
|
|||||||
$request->session()->flash('success', 'Comment deleted!');
|
$request->session()->flash('success', 'Comment deleted!');
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Notifications\NewContact;
|
|
||||||
use App\User;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use GuzzleHttp;
|
||||||
|
use App\Notifications\NewContact;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
|
||||||
class ContactController extends Controller
|
class ContactController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(User $users)
|
public function __construct(User $users)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function create(Request $request)
|
public function create(Request $request)
|
||||||
{
|
{
|
||||||
$name = $request->name;
|
$name = $request->name;
|
||||||
@ -48,29 +34,32 @@ class ContactController extends Controller
|
|||||||
$verifyrequest = Http::asForm()->post(config('recaptcha.verify.apiurl'), [
|
$verifyrequest = Http::asForm()->post(config('recaptcha.verify.apiurl'), [
|
||||||
'secret' => config('recaptcha.keys.secret'),
|
'secret' => config('recaptcha.keys.secret'),
|
||||||
'response' => $challenge,
|
'response' => $challenge,
|
||||||
'remoteip' => $request->ip(),
|
'remoteip' => $request->ip()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$response = json_decode($verifyrequest->getBody(), true);
|
$response = json_decode($verifyrequest->getBody(), true);
|
||||||
|
|
||||||
if (! $response['success']) {
|
if (!$response['success'])
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'Beep beep boop... Robot? Submission failed.');
|
$request->session()->flash('error', 'Beep beep boop... Robot? Submission failed.');
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (User::all() as $user) {
|
|
||||||
if ($user->hasRole('admin')) {
|
foreach(User::all() as $user)
|
||||||
|
{
|
||||||
|
if ($user->hasRole('admin'))
|
||||||
|
{
|
||||||
$user->notify(new NewContact(collect([
|
$user->notify(new NewContact(collect([
|
||||||
'message' => $msg,
|
'message' => $msg,
|
||||||
'ip' => $request->ip(),
|
'ip' => $request->ip(),
|
||||||
'email' => $email,
|
'email' => $email
|
||||||
])));
|
])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->session()->flash('success', 'Message sent successfully! We usually respond within 48 hours.');
|
$request->session()->flash('success', 'Message sent successfully! We usually respond within 48 hours.');
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
@ -1,32 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Application;
|
use Illuminate\Http\Request;
|
||||||
use App\User;
|
|
||||||
use App\Vacancy;
|
use App\Vacancy;
|
||||||
|
use App\User;
|
||||||
|
use App\Ban;
|
||||||
|
use App\Application;
|
||||||
|
|
||||||
class DashboardController extends Controller
|
class DashboardController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$totalPeerReview = Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get()->count();
|
$totalPeerReview = Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get()->count();
|
||||||
@ -39,7 +23,9 @@ class DashboardController extends Controller
|
|||||||
'totalUserCount' => User::all()->count(),
|
'totalUserCount' => User::all()->count(),
|
||||||
'totalDenied' => $totalDenied,
|
'totalDenied' => $totalDenied,
|
||||||
'totalPeerReview' => $totalPeerReview,
|
'totalPeerReview' => $totalPeerReview,
|
||||||
'totalNewApplications' => $totalNewApplications,
|
'totalNewApplications' => $totalNewApplications
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Application;
|
use App\Application;
|
||||||
use App\Events\ApplicationApprovedEvent;
|
use App\Events\ApplicationApprovedEvent;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class DevToolsController extends Controller
|
class DevToolsController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
// The use case for Laravel's gate and/or validation Requests is so tiny here that a full-blown policy would be overkill.
|
// The use case for Laravel's gate and/or validation Requests is so tiny here that a full-blown policy would be overkill.
|
||||||
protected function isolatedAuthorise()
|
protected function isolatedAuthorise()
|
||||||
{
|
{
|
||||||
if (! Auth::user()->can('admin.developertools.use')) {
|
if (!Auth::user()->can('admin.developertools.use'))
|
||||||
|
{
|
||||||
abort(403, 'You\'re not authorized to access this page.');
|
abort(403, 'You\'re not authorized to access this page.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,7 +23,6 @@ class DevToolsController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->isolatedAuthorise();
|
$this->isolatedAuthorise();
|
||||||
|
|
||||||
return view('dashboard.administration.devtools')
|
return view('dashboard.administration.devtools')
|
||||||
->with('applications', Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get());
|
->with('applications', Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get());
|
||||||
}
|
}
|
||||||
@ -49,11 +32,14 @@ class DevToolsController extends Controller
|
|||||||
$this->isolatedAuthorise();
|
$this->isolatedAuthorise();
|
||||||
$application = Application::find($request->application);
|
$application = Application::find($request->application);
|
||||||
|
|
||||||
if (! is_null($application)) {
|
if (!is_null($application))
|
||||||
|
{
|
||||||
event(new ApplicationApprovedEvent($application));
|
event(new ApplicationApprovedEvent($application));
|
||||||
|
|
||||||
$request->session()->flash('success', 'Event dispatched! Please check the debug logs for more info');
|
$request->session()->flash('success', 'Event dispatched! Please check the debug logs for more info');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'Application doesn\'t exist!');
|
$request->session()->flash('error', 'Application doesn\'t exist!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,32 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Form;
|
use App\Form;
|
||||||
use ContextAwareValidator;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use ContextAwareValidator;
|
||||||
|
|
||||||
class FormController extends Controller
|
class FormController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$forms = Form::all();
|
$forms = Form::all();
|
||||||
@ -39,35 +24,34 @@ class FormController extends Controller
|
|||||||
public function showFormBuilder()
|
public function showFormBuilder()
|
||||||
{
|
{
|
||||||
$this->authorize('viewFormbuilder', Form::class);
|
$this->authorize('viewFormbuilder', Form::class);
|
||||||
|
|
||||||
return view('dashboard.administration.formbuilder');
|
return view('dashboard.administration.formbuilder');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveForm(Request $request)
|
public function saveForm(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('create', Form::class);
|
$this->authorize('create', Form::class);
|
||||||
$fields = $request->all();
|
$fields = $request->all();
|
||||||
|
|
||||||
$contextValidation = ContextAwareValidator::getValidator($fields, true, true);
|
$contextValidation = ContextAwareValidator::getValidator($fields, true, true);
|
||||||
|
|
||||||
if (! $contextValidation->get('validator')->fails()) {
|
if (!$contextValidation->get('validator')->fails())
|
||||||
|
{
|
||||||
$storableFormStructure = $contextValidation->get('structure');
|
$storableFormStructure = $contextValidation->get('structure');
|
||||||
|
|
||||||
Form::create(
|
Form::create(
|
||||||
[
|
[
|
||||||
'formName' => $fields['formName'],
|
'formName' => $fields['formName'],
|
||||||
'formStructure' => $storableFormStructure,
|
'formStructure' => $storableFormStructure,
|
||||||
'formStatus' => 'ACTIVE',
|
'formStatus' => 'ACTIVE'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$request->session()->flash('success', 'Form created! You can now link this form to a vacancy.');
|
$request->session()->flash('success', 'Form created! You can now link this form to a vacancy.');
|
||||||
|
|
||||||
return redirect()->to(route('showForms'));
|
return redirect()->to(route('showForms'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages());
|
$request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages());
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,19 +60,25 @@ class FormController extends Controller
|
|||||||
$this->authorize('delete', $form);
|
$this->authorize('delete', $form);
|
||||||
$deletable = true;
|
$deletable = true;
|
||||||
|
|
||||||
if (! is_null($form) && ! is_null($form->vacancies) && $form->vacancies->count() !== 0 || ! is_null($form->responses)) {
|
|
||||||
|
if (!is_null($form) && !is_null($form->vacancies) && $form->vacancies->count() !== 0 || !is_null($form->responses))
|
||||||
|
{
|
||||||
$deletable = false;
|
$deletable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($deletable) {
|
if ($deletable)
|
||||||
|
{
|
||||||
$form->delete();
|
$form->delete();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Form deleted successfully.');
|
$request->session()->flash('success', 'Form deleted successfully.');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'You cannot delete this form because it\'s tied to one or more applications and ranks, or because it doesn\'t exist.');
|
$request->session()->flash('error', 'You cannot delete this form because it\'s tied to one or more applications and ranks, or because it doesn\'t exist.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preview(Request $request, Form $form)
|
public function preview(Request $request, Form $form)
|
||||||
@ -118,7 +108,9 @@ class FormController extends Controller
|
|||||||
$contextValidation = ContextAwareValidator::getValidator($request->all(), true);
|
$contextValidation = ContextAwareValidator::getValidator($request->all(), true);
|
||||||
$this->authorize('update', $form);
|
$this->authorize('update', $form);
|
||||||
|
|
||||||
if (! $contextValidation->get('validator')->fails()) {
|
|
||||||
|
if (!$contextValidation->get('validator')->fails())
|
||||||
|
{
|
||||||
// Add the new structure into the form. New, subsquent fields will be identified by the "new" prefix
|
// Add the new structure into the form. New, subsquent fields will be identified by the "new" prefix
|
||||||
// This prefix doesn't actually change the app's behavior when it receives applications.
|
// This prefix doesn't actually change the app's behavior when it receives applications.
|
||||||
// Additionally, old applications won't of course display new and updated fields, because we can't travel into the past and get data for them
|
// Additionally, old applications won't of course display new and updated fields, because we can't travel into the past and get data for them
|
||||||
@ -126,10 +118,14 @@ class FormController extends Controller
|
|||||||
$form->save();
|
$form->save();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Hooray! Your form was updated. New applications for it\'s vacancy will use it.');
|
$request->session()->flash('success', 'Hooray! Your form was updated. New applications for it\'s vacancy will use it.');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages());
|
$request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages());
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->to(route('previewForm', ['form' => $form->id]));
|
return redirect()->to(route('previewForm', ['form' => $form->id]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Vacancy;
|
use App\Vacancy;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class HomeController extends Controller
|
class HomeController extends Controller
|
||||||
{
|
{
|
||||||
@ -32,10 +15,12 @@ class HomeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
|
||||||
$positions = Vacancy::where('vacancyStatus', 'OPEN')
|
$positions = Vacancy::where('vacancyStatus', 'OPEN')
|
||||||
->where('vacancyCount', '<>', 0)
|
->where('vacancyCount', '<>', 0)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|
||||||
return view('home')
|
return view('home')
|
||||||
->with('positions', $positions);
|
->with('positions', $positions);
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Facades\Options;
|
use App\Facades\Options;
|
||||||
use App\Options as Option;
|
use App\Options as Option;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@ -39,32 +21,39 @@ class OptionsController extends Controller
|
|||||||
// TODO: Obtain this from the facade
|
// TODO: Obtain this from the facade
|
||||||
$options = Option::all();
|
$options = Option::all();
|
||||||
|
|
||||||
|
|
||||||
return view('dashboard.administration.settings')
|
return view('dashboard.administration.settings')
|
||||||
->with('options', $options);
|
->with('options', $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveSettings(Request $request)
|
public function saveSettings(Request $request)
|
||||||
{
|
{
|
||||||
if (Auth::user()->can('admin.settings.edit')) {
|
if (Auth::user()->can('admin.settings.edit'))
|
||||||
|
{
|
||||||
Log::debug('Updating application options', [
|
Log::debug('Updating application options', [
|
||||||
'ip' => $request->ip(),
|
'ip' => $request->ip(),
|
||||||
'ua' => $request->userAgent(),
|
'ua' => $request->userAgent(),
|
||||||
'username' => Auth::user()->username,
|
'username' => Auth::user()->username
|
||||||
]);
|
]);
|
||||||
foreach ($request->all() as $optionName => $option) {
|
foreach($request->all() as $optionName => $option)
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
Log::debug('Going through option ' . $optionName);
|
Log::debug('Going through option ' . $optionName);
|
||||||
if (Options::optionExists($optionName)) {
|
if (Options::optionExists($optionName))
|
||||||
|
{
|
||||||
Log::debug('Option exists, updating to new values', [
|
Log::debug('Option exists, updating to new values', [
|
||||||
'opt' => $optionName,
|
'opt' => $optionName,
|
||||||
'new_value' => $option,
|
'new_value' => $option
|
||||||
]);
|
]);
|
||||||
Options::changeOption($optionName, $option);
|
Options::changeOption($optionName, $option);
|
||||||
}
|
}
|
||||||
} catch (\Exception $ex) {
|
}
|
||||||
|
catch(\Exception $ex)
|
||||||
|
{
|
||||||
Log::error('Unable to update options!', [
|
Log::error('Unable to update options!', [
|
||||||
'msg' => $ex->getMessage(),
|
'msg' => $ex->getMessage(),
|
||||||
'trace' => $ex->getTraceAsString(),
|
'trace' => $ex->getTraceAsString()
|
||||||
]);
|
]);
|
||||||
report($ex);
|
report($ex);
|
||||||
|
|
||||||
@ -73,10 +62,13 @@ class OptionsController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($errorCond)) {
|
if (!isset($errorCond))
|
||||||
|
{
|
||||||
$request->session()->flash('success', 'Settings saved successfully!');
|
$request->session()->flash('success', 'Settings saved successfully!');
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'You do not have permission to update this resource.');
|
$request->session()->flash('error', 'You do not have permission to update this resource.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,29 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Facades\IP;
|
|
||||||
use App\Http\Requests\ProfileSave;
|
use App\Http\Requests\ProfileSave;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use App\Profile;
|
||||||
use App\User;
|
use App\User;
|
||||||
|
use App\Facades\IP;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@ -31,15 +14,18 @@ use Spatie\Permission\Models\Role;
|
|||||||
|
|
||||||
class ProfileController extends Controller
|
class ProfileController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
|
||||||
return view('dashboard.user.directory')
|
return view('dashboard.user.directory')
|
||||||
->with('users', User::with('profile', 'bans')->paginate(9));
|
->with('users', User::with('profile', 'bans')->paginate(9));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showProfile()
|
public function showProfile()
|
||||||
{
|
{
|
||||||
$socialLinks = Auth::user()->profile->socialLinks ?? '[]';
|
|
||||||
|
$socialLinks = Auth::user()->profile->socialLinks ?? "[]";
|
||||||
$socialMediaProfiles = json_decode($socialLinks, true);
|
$socialMediaProfiles = json_decode($socialLinks, true);
|
||||||
|
|
||||||
return view('dashboard.user.profile.userprofile')
|
return view('dashboard.user.profile.userprofile')
|
||||||
@ -50,11 +36,13 @@ class ProfileController extends Controller
|
|||||||
'insta' => $socialMediaProfiles['links']['insta'] ?? 'UpdateMe',
|
'insta' => $socialMediaProfiles['links']['insta'] ?? 'UpdateMe',
|
||||||
'discord' => $socialMediaProfiles['links']['discord'] ?? 'UpdateMe#12345',
|
'discord' => $socialMediaProfiles['links']['discord'] ?? 'UpdateMe#12345',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route model binding
|
// Route model binding
|
||||||
public function showSingleProfile(Request $request, User $user)
|
public function showSingleProfile(Request $request, User $user)
|
||||||
{
|
{
|
||||||
|
|
||||||
$socialMediaProfiles = json_decode($user->profile->socialLinks, true);
|
$socialMediaProfiles = json_decode($user->profile->socialLinks, true);
|
||||||
$createdDate = Carbon::parse($user->created_at);
|
$createdDate = Carbon::parse($user->created_at);
|
||||||
|
|
||||||
@ -63,15 +51,21 @@ class ProfileController extends Controller
|
|||||||
|
|
||||||
$roleList = [];
|
$roleList = [];
|
||||||
|
|
||||||
foreach ($systemRoles as $role) {
|
|
||||||
if (in_array($role, $userRoles)) {
|
foreach($systemRoles as $role)
|
||||||
|
{
|
||||||
|
if (in_array($role, $userRoles))
|
||||||
|
{
|
||||||
$roleList[$role] = true;
|
$roleList[$role] = true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$roleList[$role] = false;
|
$roleList[$role] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Auth::user()->is($user) || Auth::user()->can('profiles.view.others')) {
|
if (Auth::user()->is($user) || Auth::user()->can('profiles.view.others'))
|
||||||
|
{
|
||||||
return view('dashboard.user.profile.displayprofile')
|
return view('dashboard.user.profile.displayprofile')
|
||||||
->with([
|
->with([
|
||||||
'profile' => $user->profile,
|
'profile' => $user->profile,
|
||||||
@ -79,13 +73,16 @@ class ProfileController extends Controller
|
|||||||
'twitter' => $socialMediaProfiles['links']['twitter'] ?? 'UpdateMe',
|
'twitter' => $socialMediaProfiles['links']['twitter'] ?? 'UpdateMe',
|
||||||
'insta' => $socialMediaProfiles['links']['insta'] ?? 'UpdateMe',
|
'insta' => $socialMediaProfiles['links']['insta'] ?? 'UpdateMe',
|
||||||
'discord' => $socialMediaProfiles['links']['discord'] ?? 'UpdateMe#12345',
|
'discord' => $socialMediaProfiles['links']['discord'] ?? 'UpdateMe#12345',
|
||||||
'since' => $createdDate->englishMonth.' '.$createdDate->year,
|
'since' => $createdDate->englishMonth . " " . $createdDate->year,
|
||||||
'ipInfo' => IP::lookup($user->originalIP),
|
'ipInfo' => IP::lookup($user->originalIP),
|
||||||
'roles' => $roleList,
|
'roles' => $roleList
|
||||||
]);
|
]);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
abort(403, 'You cannot view someone else\'s profile.');
|
abort(403, 'You cannot view someone else\'s profile.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveProfile(ProfileSave $request)
|
public function saveProfile(ProfileSave $request)
|
||||||
@ -93,8 +90,10 @@ class ProfileController extends Controller
|
|||||||
$profile = User::find(Auth::user()->id)->profile;
|
$profile = User::find(Auth::user()->id)->profile;
|
||||||
$social = [];
|
$social = [];
|
||||||
|
|
||||||
if (! is_null($profile)) {
|
if (!is_null($profile))
|
||||||
switch ($request->avatarPref) {
|
{
|
||||||
|
switch ($request->avatarPref)
|
||||||
|
{
|
||||||
case 'MOJANG':
|
case 'MOJANG':
|
||||||
$avatarPref = 'crafatar';
|
$avatarPref = 'crafatar';
|
||||||
|
|
||||||
@ -118,8 +117,11 @@ class ProfileController extends Controller
|
|||||||
$newProfile = $profile->save();
|
$newProfile = $profile->save();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Profile settings saved successfully.');
|
$request->session()->flash('success', 'Profile settings saved successfully.');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class ResponseController extends Controller
|
class ResponseController extends Controller
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@ -1,26 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class StaffProfileController extends Controller
|
class StaffProfileController extends Controller
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@ -1,47 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Ban;
|
|
||||||
use App\Http\Requests\Add2FASecretRequest;
|
|
||||||
use App\Http\Requests\ChangeEmailRequest;
|
use App\Http\Requests\ChangeEmailRequest;
|
||||||
use App\Http\Requests\ChangePasswordRequest;
|
use App\Http\Requests\ChangePasswordRequest;
|
||||||
use App\Http\Requests\DeleteUserRequest;
|
|
||||||
use App\Http\Requests\FlushSessionsRequest;
|
use App\Http\Requests\FlushSessionsRequest;
|
||||||
use App\Http\Requests\Remove2FASecretRequest;
|
use App\Http\Requests\DeleteUserRequest;
|
||||||
use App\Http\Requests\SearchPlayerRequest;
|
use App\Http\Requests\SearchPlayerRequest;
|
||||||
use App\Http\Requests\UpdateUserRequest;
|
use App\Http\Requests\UpdateUserRequest;
|
||||||
use App\Notifications\ChangedPassword;
|
use App\Http\Requests\Add2FASecretRequest;
|
||||||
use App\Notifications\EmailChanged;
|
use App\Http\Requests\Remove2FASecretRequest;
|
||||||
|
|
||||||
use App\User;
|
use App\User;
|
||||||
use Google2FA;
|
use App\Ban;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use App\Facades\UUID;
|
||||||
|
use App\Notifications\EmailChanged;
|
||||||
|
use App\Notifications\ChangedPassword;
|
||||||
use Spatie\Permission\Models\Role;
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
|
use Google2FA;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public function showStaffMembers()
|
public function showStaffMembers()
|
||||||
{
|
{
|
||||||
$this->authorize('viewStaff', User::class);
|
$this->authorize('viewStaff', User::class);
|
||||||
@ -49,20 +36,24 @@ class UserController extends Controller
|
|||||||
$staffRoles = [
|
$staffRoles = [
|
||||||
'reviewer',
|
'reviewer',
|
||||||
'hiringManager',
|
'hiringManager',
|
||||||
'admin',
|
'admin'
|
||||||
]; // TODO: Un-hardcode this, move to config/roles.php
|
]; // TODO: Un-hardcode this, move to config/roles.php
|
||||||
$users = User::with('roles')->get();
|
$users = User::with('roles')->get();
|
||||||
$staffMembers = collect([]);
|
$staffMembers = collect([]);
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach($users as $user)
|
||||||
if (empty($user->roles)) {
|
{
|
||||||
|
if (empty($user->roles))
|
||||||
|
{
|
||||||
Log::debug($user->role->name);
|
Log::debug($user->role->name);
|
||||||
Log::debug('Staff list: User without role detected; Ignoring');
|
Log::debug('Staff list: User without role detected; Ignoring');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($user->roles as $role) {
|
foreach($user->roles as $role)
|
||||||
if (in_array($role->name, $staffRoles)) {
|
{
|
||||||
|
if (in_array($role->name, $staffRoles))
|
||||||
|
{
|
||||||
$staffMembers->push($user);
|
$staffMembers->push($user);
|
||||||
continue 2; // Skip directly to the next user instead of comparing more roles for the current user
|
continue 2; // Skip directly to the next user instead of comparing more roles for the current user
|
||||||
}
|
}
|
||||||
@ -71,7 +62,7 @@ class UserController extends Controller
|
|||||||
|
|
||||||
return view('dashboard.administration.staff-members')
|
return view('dashboard.administration.staff-members')
|
||||||
->with([
|
->with([
|
||||||
'users' => $staffMembers,
|
'users' => $staffMembers
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,9 +73,11 @@ class UserController extends Controller
|
|||||||
$users = User::with('roles')->get();
|
$users = User::with('roles')->get();
|
||||||
$players = collect([]);
|
$players = collect([]);
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach($users as $user)
|
||||||
|
{
|
||||||
// TODO: Might be problematic if we don't check if the role is user
|
// TODO: Might be problematic if we don't check if the role is user
|
||||||
if (count($user->roles) == 1) {
|
if (count($user->roles) == 1)
|
||||||
|
{
|
||||||
$players->push($user);
|
$players->push($user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,10 +85,11 @@ class UserController extends Controller
|
|||||||
return view('dashboard.administration.players')
|
return view('dashboard.administration.players')
|
||||||
->with([
|
->with([
|
||||||
'users' => $players,
|
'users' => $players,
|
||||||
'bannedUserCount' => Ban::all()->count(),
|
'bannedUserCount' => Ban::all()->count()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function showPlayersLike(SearchPlayerRequest $request)
|
public function showPlayersLike(SearchPlayerRequest $request)
|
||||||
{
|
{
|
||||||
$this->authorize('viewPlayers', User::class);
|
$this->authorize('viewPlayers', User::class);
|
||||||
@ -106,17 +100,18 @@ class UserController extends Controller
|
|||||||
->orWhere('email', 'LIKE', "%{$searchTerm}%")
|
->orWhere('email', 'LIKE', "%{$searchTerm}%")
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
if (! $matchingUsers->isEmpty()) {
|
if (!$matchingUsers->isEmpty())
|
||||||
$request->session()->flash('success', 'There were '.$matchingUsers->count().' user(s) matching your search.');
|
{ $request->session()->flash('success', 'There were ' . $matchingUsers->count() . ' user(s) matching your search.');
|
||||||
|
|
||||||
return view('dashboard.administration.players')
|
return view('dashboard.administration.players')
|
||||||
->with([
|
->with([
|
||||||
'users' => $matchingUsers,
|
'users' => $matchingUsers,
|
||||||
'bannedUserCount' => Ban::all()->count(),
|
'bannedUserCount' => Ban::all()->count()
|
||||||
]);
|
]);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'Your search term did not return any results.');
|
$request->session()->flash('error', 'Your search term did not return any results.');
|
||||||
|
|
||||||
return redirect(route('registeredPlayerList'));
|
return redirect(route('registeredPlayerList'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,10 +120,14 @@ class UserController extends Controller
|
|||||||
{
|
{
|
||||||
$QRCode = null;
|
$QRCode = null;
|
||||||
|
|
||||||
if (! $request->user()->has2FA()) {
|
if (!$request->user()->has2FA())
|
||||||
if ($request->session()->has('twofaAttemptFailed')) {
|
{
|
||||||
|
if ($request->session()->has('twofaAttemptFailed'))
|
||||||
|
{
|
||||||
$twoFactorSecret = $request->session()->get('current2FA');
|
$twoFactorSecret = $request->session()->get('current2FA');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$twoFactorSecret = Google2FA::generateSecretKey(32, '');
|
$twoFactorSecret = Google2FA::generateSecretKey(32, '');
|
||||||
$request->session()->put('current2FA', $twoFactorSecret);
|
$request->session()->put('current2FA', $twoFactorSecret);
|
||||||
}
|
}
|
||||||
@ -145,6 +144,7 @@ class UserController extends Controller
|
|||||||
->with('twofaQRCode', $QRCode);
|
->with('twofaQRCode', $QRCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function flushSessions(FlushSessionsRequest $request)
|
public function flushSessions(FlushSessionsRequest $request)
|
||||||
{
|
{
|
||||||
// TODO: Move all log calls to a listener, which binds to an event fired by each significant event, such as this one
|
// TODO: Move all log calls to a listener, which binds to an event fired by each significant event, such as this one
|
||||||
@ -155,11 +155,10 @@ class UserController extends Controller
|
|||||||
[
|
[
|
||||||
'originIPAddress' => $request->ip(),
|
'originIPAddress' => $request->ip(),
|
||||||
'userID' => Auth::user()->id,
|
'userID' => Auth::user()->id,
|
||||||
'timestamp' => now(),
|
'timestamp' => now()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$request->session()->flash('success', 'Successfully logged out other devices. Remember to change your password if you think you\'ve been compromised.');
|
$request->session()->flash('success', 'Successfully logged out other devices. Remember to change your password if you think you\'ve been compromised.');
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,62 +166,75 @@ class UserController extends Controller
|
|||||||
{
|
{
|
||||||
$user = User::find(Auth::user()->id);
|
$user = User::find(Auth::user()->id);
|
||||||
|
|
||||||
if (! is_null($user)) {
|
if (!is_null($user))
|
||||||
|
{
|
||||||
$user->password = Hash::make($request->newPassword);
|
$user->password = Hash::make($request->newPassword);
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
Log::info('User ' . $user->name . ' has changed their password', [
|
Log::info('User ' . $user->name . ' has changed their password', [
|
||||||
'originIPAddress' => $request->ip(),
|
'originIPAddress' => $request->ip(),
|
||||||
'userID' => $user->id,
|
'userID' => $user->id,
|
||||||
'timestamp' => now(),
|
'timestamp' => now()
|
||||||
]);
|
]);
|
||||||
$user->notify(new ChangedPassword());
|
$user->notify(new ChangedPassword());
|
||||||
|
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changeEmail(ChangeEmailRequest $request)
|
public function changeEmail(ChangeEmailRequest $request)
|
||||||
{
|
{
|
||||||
$user = User::find(Auth::user()->id);
|
$user = User::find(Auth::user()->id);
|
||||||
|
|
||||||
if (! is_null($user)) {
|
if (!is_null($user))
|
||||||
|
{
|
||||||
$user->email = $request->newEmail;
|
$user->email = $request->newEmail;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
Log::notice('User ' . $user->name . ' has just changed their contact email address', [
|
Log::notice('User ' . $user->name . ' has just changed their contact email address', [
|
||||||
'originIPAddress' => $request->ip(),
|
'originIPAddress' => $request->ip(),
|
||||||
'userID' => $user->id,
|
'userID' => $user->id,
|
||||||
'timestamp' => now(),
|
'timestamp' => now()
|
||||||
]);
|
]);
|
||||||
$user->notify(new EmailChanged());
|
$user->notify(new EmailChanged());
|
||||||
|
|
||||||
$request->session()->flash('success', 'Your email address has been changed!');
|
$request->session()->flash('success', 'Your email address has been changed!');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'There has been an error whilst trying to update your account. Please contact administrators.');
|
$request->session()->flash('error', 'There has been an error whilst trying to update your account. Please contact administrators.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function delete(DeleteUserRequest $request, User $user)
|
public function delete(DeleteUserRequest $request, User $user)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('delete', $user);
|
$this->authorize('delete', $user);
|
||||||
|
|
||||||
if ($request->confirmPrompt == 'DELETE ACCOUNT') {
|
if ($request->confirmPrompt == 'DELETE ACCOUNT')
|
||||||
|
{
|
||||||
$user->delete();
|
$user->delete();
|
||||||
$request->session()->flash('success','User deleted successfully. PII has been erased.');
|
$request->session()->flash('success','User deleted successfully. PII has been erased.');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'Wrong confirmation text! Try again.');
|
$request->session()->flash('error', 'Wrong confirmation text! Try again.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return redirect()->route('registeredPlayerList');
|
return redirect()->route('registeredPlayerList');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(UpdateUserRequest $request, User $user)
|
public function update(UpdateUserRequest $request, User $user)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('adminEdit', $user);
|
$this->authorize('adminEdit', $user);
|
||||||
|
|
||||||
// Mass update would not be possible here without extra code, making route model binding useless
|
// Mass update would not be possible here without extra code, making route model binding useless
|
||||||
@ -237,22 +249,28 @@ class UserController extends Controller
|
|||||||
$roleDiff = array_diff($existingRoles, $request->roles);
|
$roleDiff = array_diff($existingRoles, $request->roles);
|
||||||
|
|
||||||
// Adds roles that were selected. Removes roles that aren't selected if the user has them.
|
// Adds roles that were selected. Removes roles that aren't selected if the user has them.
|
||||||
foreach ($roleDiff as $deselectedRole) {
|
foreach($roleDiff as $deselectedRole)
|
||||||
if ($user->hasRole($deselectedRole) && $deselectedRole !== 'user') {
|
{
|
||||||
|
if ($user->hasRole($deselectedRole) && $deselectedRole !== 'user')
|
||||||
|
{
|
||||||
$user->removeRole($deselectedRole);
|
$user->removeRole($deselectedRole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($request->roles as $role) {
|
foreach($request->roles as $role)
|
||||||
if (! $user->hasRole($role)) {
|
{
|
||||||
|
if (!$user->hasRole($role))
|
||||||
|
{
|
||||||
$user->assignRole($role);
|
$user->assignRole($role);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->save();
|
$user->save();
|
||||||
$request->session()->flash('success', 'User updated successfully!');
|
$request->session()->flash('success', 'User updated successfully!');
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add2FASecret(Add2FASecretRequest $request)
|
public function add2FASecret(Add2FASecretRequest $request)
|
||||||
@ -260,30 +278,33 @@ class UserController extends Controller
|
|||||||
$currentSecret = $request->session()->get('current2FA');
|
$currentSecret = $request->session()->get('current2FA');
|
||||||
$isValid = Google2FA::verifyKey($currentSecret, $request->otp);
|
$isValid = Google2FA::verifyKey($currentSecret, $request->otp);
|
||||||
|
|
||||||
if ($isValid) {
|
if ($isValid)
|
||||||
|
{
|
||||||
$request->user()->twofa_secret = $currentSecret;
|
$request->user()->twofa_secret = $currentSecret;
|
||||||
$request->user()->save();
|
$request->user()->save();
|
||||||
|
|
||||||
Log::warning('SECURITY: User activated two-factor authentication', [
|
Log::warning('SECURITY: User activated two-factor authentication', [
|
||||||
'initiator' => $request->user()->email,
|
'initiator' => $request->user()->email,
|
||||||
'ip' => $request->ip(),
|
'ip' => $request->ip()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Google2FA::login();
|
Google2FA::login();
|
||||||
|
|
||||||
Log::warning('SECURITY: Started two factor session automatically', [
|
Log::warning('SECURITY: Started two factor session automatically', [
|
||||||
'initiator' => $request->user()->email,
|
'initiator' => $request->user()->email,
|
||||||
'ip' => $request->ip(),
|
'ip' => $request->ip()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$request->session()->forget('current2FA');
|
$request->session()->forget('current2FA');
|
||||||
|
|
||||||
if ($request->session()->has('twofaAttemptFailed')) {
|
if ($request->session()->has('twofaAttemptFailed'))
|
||||||
$request->session()->forget('twofaAttemptFailed');
|
$request->session()->forget('twofaAttemptFailed');
|
||||||
}
|
|
||||||
|
|
||||||
$request->session()->flash('success', '2FA succesfully enabled! You\'ll now be prompted for an OTP each time you log in.');
|
$request->session()->flash('success', '2FA succesfully enabled! You\'ll now be prompted for an OTP each time you log in.');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'Incorrect code. Please reopen the 2FA settings panel and try again.');
|
$request->session()->flash('error', 'Incorrect code. Please reopen the 2FA settings panel and try again.');
|
||||||
$request->session()->put('twofaAttemptFailed', true);
|
$request->session()->put('twofaAttemptFailed', true);
|
||||||
}
|
}
|
||||||
@ -295,30 +316,34 @@ class UserController extends Controller
|
|||||||
{
|
{
|
||||||
Log::warning('SECURITY: Disabling two factor authentication (user initiated)', [
|
Log::warning('SECURITY: Disabling two factor authentication (user initiated)', [
|
||||||
'initiator' => $request->user()->email,
|
'initiator' => $request->user()->email,
|
||||||
'ip' => $request->ip(),
|
'ip' => $request->ip()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$request->user()->twofa_secret = null;
|
$request->user()->twofa_secret = null;
|
||||||
$request->user()->save();
|
$request->user()->save();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Two-factor authentication disabled.');
|
$request->session()->flash('success', 'Two-factor authentication disabled.');
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function terminate(Request $request, User $user)
|
public function terminate(Request $request, User $user)
|
||||||
{
|
{
|
||||||
$this->authorize('terminate', User::class);
|
$this->authorize('terminate', User::class);
|
||||||
|
|
||||||
// TODO: move logic to policy
|
// TODO: move logic to policy
|
||||||
if (! $user->isStaffMember() || $user->is(Auth::user())) {
|
if (!$user->isStaffMember() || $user->is(Auth::user()))
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'You cannot terminate this user.');
|
$request->session()->flash('error', 'You cannot terminate this user.');
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($user->roles as $role) {
|
foreach ($user->roles as $role)
|
||||||
if ($role->name == 'user') {
|
{
|
||||||
|
if ($role->name == 'user')
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,45 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Form;
|
|
||||||
use App\Http\Requests\VacancyEditRequest;
|
|
||||||
use App\Http\Requests\VacancyRequest;
|
use App\Http\Requests\VacancyRequest;
|
||||||
use App\Notifications\VacancyClosed;
|
use App\Http\Requests\VacancyEditRequest;
|
||||||
use App\User;
|
|
||||||
use App\Vacancy;
|
use App\Vacancy;
|
||||||
|
use App\User;
|
||||||
|
use App\Form;
|
||||||
|
|
||||||
|
use App\Notifications\VacancyClosed;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
|
||||||
class VacancyController extends Controller
|
class VacancyController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->authorize('viewAny', Vacancy::class);
|
$this->authorize('viewAny', Vacancy::class);
|
||||||
|
|
||||||
return view('dashboard.administration.positions')
|
return view('dashboard.administration.positions')
|
||||||
->with([
|
->with([
|
||||||
'forms' => Form::all(),
|
'forms' => Form::all(),
|
||||||
'vacancies' => Vacancy::all(),
|
'vacancies' => Vacancy::all()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +33,8 @@ class VacancyController extends Controller
|
|||||||
$this->authorize('create', Vacancy::class);
|
$this->authorize('create', Vacancy::class);
|
||||||
$form = Form::find($request->vacancyFormID);
|
$form = Form::find($request->vacancyFormID);
|
||||||
|
|
||||||
if (! is_null($form)) {
|
if (!is_null($form))
|
||||||
|
{
|
||||||
/* note: since we can't convert HTML back to Markdown, we'll have to do the converting when the user requests a page,
|
/* note: since we can't convert HTML back to Markdown, we'll have to do the converting when the user requests a page,
|
||||||
* and leave the database with Markdown only so it can be used and edited everywhere.
|
* and leave the database with Markdown only so it can be used and edited everywhere.
|
||||||
* for several vacancies, this would require looping through all of them and replacing MD with HTML, which is obviously not the most clean solution;
|
* for several vacancies, this would require looping through all of them and replacing MD with HTML, which is obviously not the most clean solution;
|
||||||
@ -63,38 +49,46 @@ class VacancyController extends Controller
|
|||||||
'permissionGroupName' => $request->permissionGroup,
|
'permissionGroupName' => $request->permissionGroup,
|
||||||
'discordRoleID' => $request->discordRole,
|
'discordRoleID' => $request->discordRole,
|
||||||
'vacancyFormID' => $request->vacancyFormID,
|
'vacancyFormID' => $request->vacancyFormID,
|
||||||
'vacancyCount' => $request->vacancyCount,
|
'vacancyCount' => $request->vacancyCount
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$request->session()->flash('success', 'Vacancy successfully opened. It will now show in the home page.');
|
$request->session()->flash('success', 'Vacancy successfully opened. It will now show in the home page.');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$request->session()->flash('error', 'You cannot create a vacancy without a valid form.');
|
$request->session()->flash('error', 'You cannot create a vacancy without a valid form.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatePositionAvailability(Request $request, $status, Vacancy $vacancy)
|
public function updatePositionAvailability(Request $request, $status, Vacancy $vacancy)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('update', $vacancy);
|
$this->authorize('update', $vacancy);
|
||||||
|
|
||||||
if (! is_null($vacancy)) {
|
if (!is_null($vacancy))
|
||||||
|
{
|
||||||
$type = 'success';
|
$type = 'success';
|
||||||
|
|
||||||
switch ($status) {
|
switch ($status)
|
||||||
|
{
|
||||||
case 'open':
|
case 'open':
|
||||||
$vacancy->open();
|
$vacancy->open();
|
||||||
$message = 'Position successfully opened!';
|
$message = "Position successfully opened!";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'close':
|
case 'close':
|
||||||
$vacancy->close();
|
$vacancy->close();
|
||||||
$message = 'Position successfully closed!';
|
$message = "Position successfully closed!";
|
||||||
|
|
||||||
foreach (User::all() as $user) {
|
foreach(User::all() as $user)
|
||||||
if ($user->isStaffMember()) {
|
{
|
||||||
|
if ($user->isStaffMember())
|
||||||
|
{
|
||||||
$user->notify(new VacancyClosed($vacancy));
|
$user->notify(new VacancyClosed($vacancy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,24 +99,27 @@ class VacancyController extends Controller
|
|||||||
$type = 'error';
|
$type = 'error';
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$message = "The position you're trying to update doesn't exist!";
|
$message = "The position you're trying to update doesn't exist!";
|
||||||
$type = 'error';
|
$type = "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->session()->flash($type, $message);
|
$request->session()->flash($type, $message);
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function edit(Request $request, Vacancy $vacancy)
|
public function edit(Request $request, Vacancy $vacancy)
|
||||||
{
|
{
|
||||||
$this->authorize('update', $vacancy);
|
$this->authorize('update', $vacancy);
|
||||||
|
|
||||||
return view('dashboard.administration.editposition')
|
return view('dashboard.administration.editposition')
|
||||||
->with('vacancy', $vacancy);
|
->with('vacancy', $vacancy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function update(VacancyEditRequest $request, Vacancy $vacancy)
|
public function update(VacancyEditRequest $request, Vacancy $vacancy)
|
||||||
{
|
{
|
||||||
$this->authorize('update', $vacancy);
|
$this->authorize('update', $vacancy);
|
||||||
@ -134,7 +131,8 @@ class VacancyController extends Controller
|
|||||||
$vacancy->save();
|
$vacancy->save();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Vacancy successfully updated.');
|
$request->session()->flash('success', 'Vacancy successfully updated.');
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Application;
|
use App\Application;
|
||||||
use App\Http\Requests\VoteRequest;
|
use App\Http\Requests\VoteRequest;
|
||||||
|
use App\Jobs\ProcessVoteList;
|
||||||
use App\Vote;
|
use App\Vote;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class VoteController extends Controller
|
class VoteController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function vote(VoteRequest $voteRequest, Application $application)
|
public function vote(VoteRequest $voteRequest, Application $application)
|
||||||
{
|
{
|
||||||
$this->authorize('create', Vote::class);
|
$this->authorize('create', Vote::class);
|
||||||
@ -39,8 +23,9 @@ class VoteController extends Controller
|
|||||||
]);
|
]);
|
||||||
$vote->application()->attach($application->id);
|
$vote->application()->attach($application->id);
|
||||||
|
|
||||||
|
|
||||||
Log::info('User ' . Auth::user()->name . ' has voted in applicant ' . $application->user->name . '\'s application', [
|
Log::info('User ' . Auth::user()->name . ' has voted in applicant ' . $application->user->name . '\'s application', [
|
||||||
'voteType' => $voteRequest->voteType,
|
'voteType' => $voteRequest->voteType
|
||||||
]);
|
]);
|
||||||
$voteRequest->session()->flash('success', 'Your vote has been registered!');
|
$voteRequest->session()->flash('success', 'Your vote has been registered!');
|
||||||
|
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http;
|
namespace App\Http;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
@ -89,6 +70,6 @@ class Kernel extends HttpKernel
|
|||||||
'localizationRedirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class,
|
'localizationRedirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class,
|
||||||
'localeSessionRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class,
|
'localeSessionRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class,
|
||||||
'localeCookieRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleCookieRedirect::class,
|
'localeCookieRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleCookieRedirect::class,
|
||||||
'localeViewPath' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationViewPath::class,
|
'localeViewPath' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationViewPath::class
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use App\Application;
|
use App\Application;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Facades\View;
|
use Illuminate\Support\Facades\View;
|
||||||
|
|
||||||
class ApplicationEligibility
|
class ApplicationEligibility
|
||||||
@ -42,16 +23,22 @@ class ApplicationEligibility
|
|||||||
{
|
{
|
||||||
$curtime = new Carbon(now());
|
$curtime = new Carbon(now());
|
||||||
|
|
||||||
if (Auth::check()) {
|
|
||||||
|
if (Auth::check())
|
||||||
|
{
|
||||||
$applications = Application::where('applicantUserID', Auth::user()->id)->get();
|
$applications = Application::where('applicantUserID', Auth::user()->id)->get();
|
||||||
$eligible = true;
|
$eligible = true;
|
||||||
|
|
||||||
$daysRemaining = 0;
|
$daysRemaining = 0;
|
||||||
|
|
||||||
if (! $applications->isEmpty()) {
|
if (!$applications->isEmpty())
|
||||||
foreach ($applications as $application) {
|
{
|
||||||
|
foreach ($applications as $application)
|
||||||
|
{
|
||||||
$appTime = Carbon::parse($application->created_at);
|
$appTime = Carbon::parse($application->created_at);
|
||||||
if ($appTime->isSameMonth($curtime)) {
|
if ($appTime->isSameMonth($curtime))
|
||||||
|
{
|
||||||
|
|
||||||
Log::warning('Notice: Application ID ' . $application->id . ' was found to be in the same month as today\'s time, making the user ' . Auth::user()->name . ' ineligible for application');
|
Log::warning('Notice: Application ID ' . $application->id . ' was found to be in the same month as today\'s time, making the user ' . Auth::user()->name . ' ineligible for application');
|
||||||
$eligible = false;
|
$eligible = false;
|
||||||
}
|
}
|
||||||
@ -59,12 +46,14 @@ class ApplicationEligibility
|
|||||||
|
|
||||||
$allowedTime = Carbon::parse($applications->last()->created_at)->addMonth();
|
$allowedTime = Carbon::parse($applications->last()->created_at)->addMonth();
|
||||||
$daysRemaining = $allowedTime->diffInDays(now());
|
$daysRemaining = $allowedTime->diffInDays(now());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
View::share('isEligibleForApplication', $eligible);
|
View::share('isEligibleForApplication', $eligible);
|
||||||
View::share('eligibilityDaysRemaining', $daysRemaining);
|
View::share('eligibilityDaysRemaining', $daysRemaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
@ -39,11 +20,17 @@ class Bancheck
|
|||||||
$userIP = $request->ip();
|
$userIP = $request->ip();
|
||||||
$anonymousUser = User::where('ipAddress', $userIP)->get();
|
$anonymousUser = User::where('ipAddress', $userIP)->get();
|
||||||
|
|
||||||
if (Auth::check() && Auth::user()->isBanned()) {
|
|
||||||
|
if (Auth::check() && Auth::user()->isBanned())
|
||||||
|
{
|
||||||
View::share('isBanned', true);
|
View::share('isBanned', true);
|
||||||
} elseif (! $anonymousUser->isEmpty() && User::find($anonymousUser->id)->isBanned()) {
|
}
|
||||||
|
elseif(!$anonymousUser->isEmpty() && User::find($anonymousUser->id)->isBanned())
|
||||||
|
{
|
||||||
View::share('isBanned', true);
|
View::share('isBanned', true);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
View::share('isBanned', false);
|
View::share('isBanned', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
@ -35,11 +16,11 @@ class ForceLogoutMiddleware
|
|||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
if (Auth::user()->isBanned()) {
|
if (Auth::user()->isBanned())
|
||||||
|
{
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
|
|
||||||
$request->session()->flash('error', 'Error: Your session has been forcefully terminated. Please try again in a few days.');
|
$request->session()->flash('error', 'Error: Your session has been forcefully terminated. Please try again in a few days.');
|
||||||
|
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use App\Providers\RouteServiceProvider;
|
use App\Providers\RouteServiceProvider;
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||||
@ -31,7 +12,7 @@ class TrustProxies extends Middleware
|
|||||||
*
|
*
|
||||||
* @var array|string
|
* @var array|string
|
||||||
*/
|
*/
|
||||||
protected $proxies = '*';
|
protected $proxies = "*";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The headers that should be used to detect proxies.
|
* The headers that should be used to detect proxies.
|
||||||
|
@ -1,33 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use App\Facades\UUID;
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use App\Facades\UUID;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
class UsernameUUID
|
class UsernameUUID
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Converts a Minecraft username found in the request body to a UUID.
|
* Converts a Minecraft username found in the request body to a UUID
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Closure $next
|
* @param \Closure $next
|
||||||
@ -36,21 +18,23 @@ class UsernameUUID
|
|||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
$input = $request->all();
|
$input = $request->all();
|
||||||
if (isset($input['uuid'])) {
|
if (isset($input['uuid']))
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
$username = $input['uuid'];
|
$username = $input['uuid'];
|
||||||
$input['uuid'] = UUID::toUUID($username);
|
$input['uuid'] = UUID::toUUID($username);
|
||||||
} catch (\InvalidArgumentException $iae) {
|
}
|
||||||
|
catch(\InvalidArgumentException $iae)
|
||||||
|
{
|
||||||
report($iae);
|
report($iae);
|
||||||
|
|
||||||
$request->session()->flash('error', $iae->getMessage());
|
$request->session()->flash('error', $iae->getMessage());
|
||||||
|
|
||||||
return redirect(route('register'));
|
return redirect(route('register'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->replace($input);
|
$request->replace($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -44,7 +25,7 @@ class Add2FASecretRequest extends FormRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'otp' => 'required|string|min:6|max:6',
|
'otp' => 'required|string|min:6|max:6'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
|
||||||
class BanUserRequest extends FormRequest
|
class BanUserRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -46,7 +28,7 @@ class BanUserRequest extends FormRequest
|
|||||||
return [
|
return [
|
||||||
'reason' => 'required|string',
|
'reason' => 'required|string',
|
||||||
'durationOperand' => 'nullable|string',
|
'durationOperand' => 'nullable|string',
|
||||||
'durationOperator' => 'nullable|string',
|
'durationOperator' => 'nullable|string'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -44,7 +25,7 @@ class ChangeEmailRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'currentPassword' => 'required|password',
|
'currentPassword' => 'required|password',
|
||||||
'newEmail' => 'required|email|unique:users,email',
|
'newEmail' => 'required|email|unique:users,email'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -44,7 +25,7 @@ class ChangePasswordRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'newPassword' => 'required|string|confirmed',
|
'newPassword' => 'required|string|confirmed',
|
||||||
'oldPassword' => 'required|string|password',
|
'oldPassword' => 'required|string|password'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -44,7 +25,7 @@ class DeleteUserRequest extends FormRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'confirmPrompt' => 'required|string',
|
'confirmPrompt' => 'required|string'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -43,7 +24,7 @@ class FlushSessionsRequest extends FormRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'currentPasswordFlush' => 'required|password',
|
'currentPasswordFlush' => 'required|password'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
|
||||||
class NewCommentRequest extends FormRequest
|
class NewCommentRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -45,7 +27,7 @@ class NewCommentRequest extends FormRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'comment' => 'required|string|max:600|min:20',
|
'comment' => 'required|string|max:600|min:20'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class ProfileSave extends FormRequest
|
class ProfileSave extends FormRequest
|
||||||
{
|
{
|
||||||
@ -51,7 +33,7 @@ class ProfileSave extends FormRequest
|
|||||||
'socialInsta' => 'nullable|string',
|
'socialInsta' => 'nullable|string',
|
||||||
'socialTwitter' => 'nullable|string',
|
'socialTwitter' => 'nullable|string',
|
||||||
'socialDiscord' => 'nullable|string',
|
'socialDiscord' => 'nullable|string',
|
||||||
'socialGithub' => 'nullable|string',
|
'socialGithub' => 'nullable|string'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -44,7 +25,7 @@ class Remove2FASecretRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'currentPassword' => 'required|password',
|
'currentPassword' => 'required|password',
|
||||||
'consent' => 'required|accepted',
|
'consent' => 'required|accepted'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -43,7 +24,7 @@ class SaveNotesRequest extends FormRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'noteText' => 'required|string',
|
'noteText' => 'required|string'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -44,7 +25,7 @@ class SearchPlayerRequest extends FormRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'searchTerm' => 'required|string|max:17', // max user char limit set by Mojang
|
'searchTerm' => 'required|string|max:17' // max user char limit set by Mojang
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -47,7 +28,7 @@ class UpdateUserRequest extends FormRequest
|
|||||||
'email' => 'required|email',
|
'email' => 'required|email',
|
||||||
'name' => 'required|string',
|
'name' => 'required|string',
|
||||||
'uuid' => 'required|max:32|min:32',
|
'uuid' => 'required|max:32|min:32',
|
||||||
'roles' => 'required_without_all',
|
'roles' => 'required_without_all'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
|
||||||
class VacancyEditRequest extends FormRequest
|
class VacancyEditRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -46,7 +28,7 @@ class VacancyEditRequest extends FormRequest
|
|||||||
return [
|
return [
|
||||||
'vacancyDescription' => 'required|string',
|
'vacancyDescription' => 'required|string',
|
||||||
'vacancyFullDescription' => 'nullable|string',
|
'vacancyFullDescription' => 'nullable|string',
|
||||||
'vacancyCount' => 'required|integer|min:1',
|
'vacancyCount' => 'required|integer|min:1'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -49,7 +30,7 @@ class VacancyRequest extends FormRequest
|
|||||||
'permissionGroup' => 'required|string',
|
'permissionGroup' => 'required|string',
|
||||||
'discordRole' => 'required|string',
|
'discordRole' => 'required|string',
|
||||||
'vacancyCount' => 'required|integer',
|
'vacancyCount' => 'required|integer',
|
||||||
'vacancyFormID' => 'required|integer',
|
'vacancyFormID' => 'required|integer'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -43,7 +24,7 @@ class VoteRequest extends FormRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'voteType' => 'required|string|in:VOTE_DENY,VOTE_APPROVE',
|
'voteType' => 'required|string|in:VOTE_DENY,VOTE_APPROVE'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs;
|
||||||
|
|
||||||
use App\Ban;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
@ -30,12 +9,15 @@ use Illuminate\Queue\InteractsWithQueue;
|
|||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
use App\Ban;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class CleanBans implements ShouldQueue
|
class CleanBans implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
public $bans;
|
|
||||||
|
|
||||||
|
public $bans;
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
@ -52,18 +34,23 @@ class CleanBans implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
|
||||||
Log::debug('Running automatic ban cleaner...');
|
Log::debug('Running automatic ban cleaner...');
|
||||||
$bans = Ban::all();
|
$bans = Ban::all();
|
||||||
|
|
||||||
if (! is_null($bans)) {
|
if (!is_null($bans))
|
||||||
foreach ($this->bans as $ban) {
|
{
|
||||||
|
foreach($this->bans as $ban)
|
||||||
|
{
|
||||||
$bannedUntil = Carbon::parse($ban->bannedUntil);
|
$bannedUntil = Carbon::parse($ban->bannedUntil);
|
||||||
|
|
||||||
if ($bannedUntil->equalTo(now())) {
|
if ($bannedUntil->equalTo(now()))
|
||||||
|
{
|
||||||
Log::debug('Deleted ban ' . $ban->id . ' belonging to ' . $ban->user->name);
|
Log::debug('Deleted ban ' . $ban->id . ' belonging to ' . $ban->user->name);
|
||||||
$ban->delete();
|
$ban->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\Events\ApplicationDeniedEvent;
|
use App\Events\ApplicationDeniedEvent;
|
||||||
use App\Notifications\ApplicationDenied;
|
use App\Notifications\ApplicationDenied;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class DenyUser
|
class DenyUser
|
||||||
@ -49,5 +32,6 @@ class DenyUser
|
|||||||
Log::info('User ' . $event->application->user->name . ' just had their application denied.');
|
Log::info('User ' . $event->application->user->name . ' just had their application denied.');
|
||||||
|
|
||||||
$event->application->user->notify(new ApplicationDenied($event->application));
|
$event->application->user->notify(new ApplicationDenied($event->application));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class LogAuthenticationFailure
|
class LogAuthenticationFailure
|
||||||
@ -44,9 +27,10 @@ class LogAuthenticationFailure
|
|||||||
public function handle($event)
|
public function handle($event)
|
||||||
{
|
{
|
||||||
$targetAccountID = 0;
|
$targetAccountID = 0;
|
||||||
$originalIP = '0.0.0.0';
|
$originalIP = "0.0.0.0";
|
||||||
|
|
||||||
if (isset($event->user->id)) {
|
if (isset($event->user->id))
|
||||||
|
{
|
||||||
$targetAccountID = $event->user->id;
|
$targetAccountID = $event->user->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class LogAuthenticationSuccess
|
class LogAuthenticationSuccess
|
||||||
|
@ -1,31 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use App\Events\UserBannedEvent;
|
use App\Events\UserBannedEvent;
|
||||||
use App\Notifications\UserBanned;
|
use App\Notifications\UserBanned;
|
||||||
use App\User;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
|
||||||
class OnUserBanned
|
class OnUserBanned
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -46,12 +31,16 @@ class OnUserBanned
|
|||||||
*/
|
*/
|
||||||
public function handle(UserBannedEvent $event)
|
public function handle(UserBannedEvent $event)
|
||||||
{
|
{
|
||||||
Log::warning('User '.$event->user->name.' has just been banned from the site!');
|
|
||||||
|
|
||||||
foreach (User::all() as $user) {
|
Log::warning("User " . $event->user->name . " has just been banned from the site!");
|
||||||
if ($user->isStaffMember()) {
|
|
||||||
|
foreach(User::all() as $user)
|
||||||
|
{
|
||||||
|
if ($user->isStaffMember())
|
||||||
|
{
|
||||||
$user->notify((new UserBanned($event->user, $event->ban))->delay(now()->addSeconds(10)));
|
$user->notify((new UserBanned($event->user, $event->ban))->delay(now()->addSeconds(10)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\Notifications\NewUser;
|
|
||||||
use App\User;
|
|
||||||
use Illuminate\Auth\Events\Registered;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
use App\Notifications\NewUser;
|
||||||
|
|
||||||
class OnUserRegistration
|
class OnUserRegistration
|
||||||
{
|
{
|
||||||
@ -49,8 +33,10 @@ class OnUserRegistration
|
|||||||
// TODO: Send push notification to online admins via browser (w/ pusher)
|
// TODO: Send push notification to online admins via browser (w/ pusher)
|
||||||
Log::info('User ' . $event->user->name . ' has just registered for an account.');
|
Log::info('User ' . $event->user->name . ' has just registered for an account.');
|
||||||
|
|
||||||
foreach (User::all() as $user) {
|
foreach(User::all() as $user)
|
||||||
if ($user->hasRole('admin')) {
|
{
|
||||||
|
if ($user->hasRole('admin'))
|
||||||
|
{
|
||||||
$user->notify(new NewUser($event->user));
|
$user->notify(new NewUser($event->user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\Events\ApplicationApprovedEvent;
|
use App\Events\ApplicationApprovedEvent;
|
||||||
use App\Notifications\ApplicationApproved;
|
|
||||||
use App\StaffProfile;
|
use App\StaffProfile;
|
||||||
|
use App\Notifications\ApplicationApproved;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class PromoteUser
|
class PromoteUser
|
||||||
@ -51,18 +35,19 @@ class PromoteUser
|
|||||||
$staffProfile = StaffProfile::create([
|
$staffProfile = StaffProfile::create([
|
||||||
'userID' => $event->application->user->id,
|
'userID' => $event->application->user->id,
|
||||||
'approvalDate' => now()->toDateTimeString(),
|
'approvalDate' => now()->toDateTimeString(),
|
||||||
'memberNotes' => 'Approved by staff members. Welcome them to the team!',
|
'memberNotes' => 'Approved by staff members. Welcome them to the team!'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$event->application->user->assignRole('reviewer');
|
$event->application->user->assignRole('reviewer');
|
||||||
|
|
||||||
Log::info('User ' . $event->application->user->name . ' has just been promoted!', [
|
Log::info('User ' . $event->application->user->name . ' has just been promoted!', [
|
||||||
'newRank' => $event->application->response->vacancy->permissionGroupName,
|
'newRank' => $event->application->response->vacancy->permissionGroupName,
|
||||||
'staffProfileID' => $staffProfile->id,
|
'staffProfileID' => $staffProfile->id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$event->application->user->notify(new ApplicationApproved($event->application));
|
$event->application->user->notify(new ApplicationApproved($event->application));
|
||||||
// note: Also notify staff
|
// note: Also notify staff
|
||||||
// TODO: Also assign new app role based on the permission group name
|
// TODO: Also assign new app role based on the permission group name
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Mail;
|
namespace App\Mail;
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Mail\Mailable;
|
use Illuminate\Mail\Mailable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
@ -1,27 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Application;
|
|
||||||
use App\Facades\Options;
|
use App\Facades\Options;
|
||||||
use App\Traits\Cancellable;
|
use App\Traits\Cancellable;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
@ -29,6 +9,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Messages\SlackMessage;
|
use Illuminate\Notifications\Messages\SlackMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
use App\Application;
|
||||||
|
|
||||||
class ApplicationApproved extends Notification implements ShouldQueue
|
class ApplicationApproved extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
@ -64,6 +45,7 @@ class ApplicationApproved extends Notification implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function toMail($notifiable)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->from(config('notification.sender.address'), config('notification.sender.name'))
|
->from(config('notification.sender.address'), config('notification.sender.name'))
|
||||||
->subject(config('app.name') . ' - ' . $this->application->response->vacancy->vacancyName . ' application approved')
|
->subject(config('app.name') . ' - ' . $this->application->response->vacancy->vacancyName . ' application approved')
|
||||||
@ -80,6 +62,7 @@ class ApplicationApproved extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
public function toSlack($notifiable)
|
public function toSlack($notifiable)
|
||||||
{
|
{
|
||||||
|
|
||||||
$url = route('showSingleProfile', ['user' => $notifiable->id]);
|
$url = route('showSingleProfile', ['user' => $notifiable->id]);
|
||||||
$roles = implode(', ', $notifiable->roles->pluck('name')->all());
|
$roles = implode(', ', $notifiable->roles->pluck('name')->all());
|
||||||
|
|
||||||
@ -91,7 +74,7 @@ class ApplicationApproved extends Notification implements ShouldQueue
|
|||||||
->fields([
|
->fields([
|
||||||
'Name' => $notifiable->name,
|
'Name' => $notifiable->name,
|
||||||
'Email' => $notifiable->email,
|
'Email' => $notifiable->email,
|
||||||
'Roles' => $roles,
|
'Roles' => $roles
|
||||||
])
|
])
|
||||||
->action('View profile', $url);
|
->action('View profile', $url);
|
||||||
});
|
});
|
||||||
|
@ -1,37 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Application;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Messages\SlackMessage;
|
use Illuminate\Notifications\Messages\SlackMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
use App\Application;
|
||||||
|
|
||||||
class ApplicationDenied extends Notification implements ShouldQueue
|
class ApplicationDenied extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
|
|
||||||
public $application;
|
public $application;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,6 +45,7 @@ class ApplicationDenied extends Notification implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function toMail($notifiable)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->from(config('notification.sender.address'), config('notification.sender.name'))
|
->from(config('notification.sender.address'), config('notification.sender.name'))
|
||||||
->subject(config('app.name') . ' - ' . $this->application->response->vacancy->vacancyName . ' application denied')
|
->subject(config('app.name') . ' - ' . $this->application->response->vacancy->vacancyName . ' application denied')
|
||||||
@ -73,6 +56,7 @@ class ApplicationDenied extends Notification implements ShouldQueue
|
|||||||
->line('Better luck next time!');
|
->line('Better luck next time!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function toSlack($notifiable)
|
public function toSlack($notifiable)
|
||||||
{
|
{
|
||||||
$notifiableName = $notifiable->name;
|
$notifiableName = $notifiable->name;
|
||||||
@ -84,8 +68,8 @@ class ApplicationDenied extends Notification implements ShouldQueue
|
|||||||
$attachment->title('Application denied!')
|
$attachment->title('Application denied!')
|
||||||
->content($notifiableName . '\'s application has just been denied. They can try again in 30 days.');
|
->content($notifiableName . '\'s application has just been denied. They can try again in 30 days.');
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
* Get the array representation of the notification.
|
||||||
*
|
*
|
||||||
|
@ -1,32 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Facades\Options;
|
|
||||||
use App\Traits\Cancellable;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
use App\Traits\Cancellable;
|
||||||
|
use App\Facades\Options;
|
||||||
|
|
||||||
class ApplicationMoved extends Notification implements ShouldQueue
|
class ApplicationMoved extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
@ -1,36 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Appointment;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
use App\Appointment;
|
||||||
|
|
||||||
class AppointmentScheduled extends Notification implements ShouldQueue
|
class AppointmentScheduled extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
|
|
||||||
protected $appointment;
|
protected $appointment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
@ -1,42 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Application;
|
|
||||||
use App\Facades\Options;
|
|
||||||
use App\Traits\Cancellable;
|
|
||||||
use App\Vacancy;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Messages\SlackMessage;
|
use Illuminate\Notifications\Messages\SlackMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
use App\Application;
|
||||||
|
use App\Vacancy;
|
||||||
|
|
||||||
|
use App\Traits\Cancellable;
|
||||||
|
use App\Facades\Options;
|
||||||
|
|
||||||
class NewApplicant extends Notification implements ShouldQueue
|
class NewApplicant extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable, Cancellable;
|
use Queueable, Cancellable;
|
||||||
|
|
||||||
|
|
||||||
protected $application;
|
protected $application;
|
||||||
|
|
||||||
|
|
||||||
protected $vacancy;
|
protected $vacancy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +36,8 @@ class NewApplicant extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
public function channels()
|
public function channels()
|
||||||
{
|
{
|
||||||
if (Options::getOption('enable_slack_notifications') == 1) {
|
if (Options::getOption('enable_slack_notifications') == 1)
|
||||||
|
{
|
||||||
return ['slack'];
|
return ['slack'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,8 +66,10 @@ class NewApplicant extends Notification implements ShouldQueue
|
|||||||
->line('Thank you!');
|
->line('Thank you!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function toSlack($notifiable)
|
public function toSlack($notifiable)
|
||||||
{
|
{
|
||||||
|
|
||||||
$vacancyDetails = [];
|
$vacancyDetails = [];
|
||||||
$vacancyDetails['name'] = $this->vacancy->vacancyName;
|
$vacancyDetails['name'] = $this->vacancy->vacancyName;
|
||||||
$vacancyDetails['slots'] = $this->vacancy->vacancyCount;
|
$vacancyDetails['slots'] = $this->vacancy->vacancyCount;
|
||||||
@ -98,12 +85,11 @@ class NewApplicant extends Notification implements ShouldQueue
|
|||||||
->fields([
|
->fields([
|
||||||
'Applied for' => $vacancyDetails['name'],
|
'Applied for' => $vacancyDetails['name'],
|
||||||
'Avaiable positions' => $vacancyDetails['slots'],
|
'Avaiable positions' => $vacancyDetails['slots'],
|
||||||
'Applicant' => $applicant,
|
'Applicant' => $applicant
|
||||||
])
|
])
|
||||||
->action('Review application', $url);
|
->action('Review application', $url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
* Get the array representation of the notification.
|
||||||
*
|
*
|
||||||
|
@ -1,39 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Application;
|
|
||||||
use App\Comment;
|
|
||||||
use App\Facades\Options;
|
|
||||||
use App\Traits\Cancellable;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
use App\Comment;
|
||||||
|
use App\Application;
|
||||||
|
use App\Traits\Cancellable;
|
||||||
|
use App\Facades\Options;
|
||||||
|
|
||||||
class NewComment extends Notification implements ShouldQueue
|
class NewComment extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable, Cancellable;
|
use Queueable, Cancellable;
|
||||||
|
|
||||||
|
|
||||||
protected $application;
|
protected $application;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,27 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@ -64,8 +46,9 @@ class NewContact extends Notification
|
|||||||
if ($this->message->has([
|
if ($this->message->has([
|
||||||
'message',
|
'message',
|
||||||
'ip',
|
'ip',
|
||||||
'email',
|
'email'
|
||||||
])) {
|
]))
|
||||||
|
{
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->line('We\'ve received a new contact form submission in the StaffManagement app center.')
|
->line('We\'ve received a new contact form submission in the StaffManagement app center.')
|
||||||
->line('This is what they sent: ')
|
->line('This is what they sent: ')
|
||||||
@ -77,7 +60,7 @@ class NewContact extends Notification
|
|||||||
->line('Thank you!');
|
->line('Thank you!');
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException('Invalid arguments supplied to NewContact!');
|
throw new \InvalidArgumentException("Invalid arguments supplied to NewContact!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,35 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Facades\Options;
|
|
||||||
use App\Facades\UUID;
|
|
||||||
use App\Traits\Cancellable;
|
|
||||||
use App\User;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Messages\SlackMessage;
|
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
use Illuminate\Notifications\Messages\SlackMessage;
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
use App\Facades\UUID;
|
||||||
|
use App\Traits\Cancellable;
|
||||||
|
use App\Facades\Options;
|
||||||
|
|
||||||
class NewUser extends Notification implements ShouldQueue
|
class NewUser extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
@ -89,13 +71,15 @@ class NewUser extends Notification implements ShouldQueue
|
|||||||
->success()
|
->success()
|
||||||
->content('A new user has signed up!')
|
->content('A new user has signed up!')
|
||||||
->attachment(function($attachment) use ($user){
|
->attachment(function($attachment) use ($user){
|
||||||
|
|
||||||
$attachment->title('User details')
|
$attachment->title('User details')
|
||||||
->fields([
|
->fields([
|
||||||
'Email address' => $user['email'],
|
'Email address' => $user['email'],
|
||||||
'Name' => $user['name'],
|
'Name' => $user['name'],
|
||||||
'Minecraft Username' => $user['username'],
|
'Minecraft Username' => $user['username'],
|
||||||
'Registration date' => $user['created_at'],
|
'Registration date' => $user['created_at']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,33 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Ban;
|
|
||||||
use App\User;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
use App\Ban;
|
||||||
|
|
||||||
class UserBanned extends Notification implements ShouldQueue
|
class UserBanned extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
@ -35,7 +17,6 @@ class UserBanned extends Notification implements ShouldQueue
|
|||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
protected $ban;
|
protected $ban;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new notification instance.
|
* Create a new notification instance.
|
||||||
*
|
*
|
||||||
|
@ -1,35 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Facades\Options;
|
|
||||||
use App\Traits\Cancellable;
|
|
||||||
use App\Vacancy;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
use App\Vacancy;
|
||||||
|
use App\Facades\Options;
|
||||||
|
use App\Traits\Cancellable;
|
||||||
|
|
||||||
class VacancyClosed extends Notification implements ShouldQueue
|
class VacancyClosed extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable, SerializesModels, Cancellable;
|
use Queueable, SerializesModels, Cancellable;
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Observers;
|
namespace App\Observers;
|
||||||
|
|
||||||
use App\Application;
|
use App\Application;
|
||||||
@ -53,20 +34,24 @@ class ApplicationObserver
|
|||||||
$application->response()->delete();
|
$application->response()->delete();
|
||||||
$votes = $application->votes;
|
$votes = $application->votes;
|
||||||
|
|
||||||
foreach ($votes as $vote) {
|
foreach ($votes as $vote)
|
||||||
|
{
|
||||||
Log::debug('Referential integrity cleanup: Deleting and detaching vote ' . $vote->id);
|
Log::debug('Referential integrity cleanup: Deleting and detaching vote ' . $vote->id);
|
||||||
$vote->application()->detach($application->id);
|
$vote->application()->detach($application->id);
|
||||||
$vote->delete();
|
$vote->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_null($application->appointment)) {
|
if (!is_null($application->appointment))
|
||||||
|
{
|
||||||
Log::debug('RIC: Deleting appointment!');
|
Log::debug('RIC: Deleting appointment!');
|
||||||
$application->appointment()->delete();
|
$application->appointment()->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $application->comments->isEmpty()) {
|
if (!$application->comments->isEmpty())
|
||||||
|
{
|
||||||
Log::debug('RIC: Deleting comments!');
|
Log::debug('RIC: Deleting comments!');
|
||||||
foreach ($application->comments as $comment) {
|
foreach($application->comments as $comment)
|
||||||
|
{
|
||||||
$comment->delete();
|
$comment->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Observers;
|
namespace App\Observers;
|
||||||
|
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
@ -40,7 +21,7 @@ class UserObserver
|
|||||||
'profileShortBio' => 'Write a one-liner about you here!',
|
'profileShortBio' => 'Write a one-liner about you here!',
|
||||||
'profileAboutMe' => 'Tell us a bit about you.',
|
'profileAboutMe' => 'Tell us a bit about you.',
|
||||||
'socialLinks' => '{}',
|
'socialLinks' => '{}',
|
||||||
'userID' => $user->id,
|
'userID' => $user->id
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -62,12 +43,15 @@ class UserObserver
|
|||||||
Log::debug('Referential integrity cleanup: Deleted profile!');
|
Log::debug('Referential integrity cleanup: Deleted profile!');
|
||||||
$applications = $user->applications;
|
$applications = $user->applications;
|
||||||
|
|
||||||
if (! $applications->isEmpty()) {
|
if (!$applications->isEmpty())
|
||||||
|
{
|
||||||
Log::debug('RIC: Now trying to delete applications and responses...');
|
Log::debug('RIC: Now trying to delete applications and responses...');
|
||||||
foreach ($applications as $application) {
|
foreach($applications as $application)
|
||||||
|
{
|
||||||
// code moved to Application observer, where it gets rid of attached elements individually
|
// code moved to Application observer, where it gets rid of attached elements individually
|
||||||
Log::debug('RIC: Deleting application ' . $application->id);
|
Log::debug('RIC: Deleting application ' . $application->id);
|
||||||
$application->delete();
|
$application->delete();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,28 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Observers;
|
namespace App\Observers;
|
||||||
|
|
||||||
use App\Vacancy;
|
use App\Vacancy;
|
||||||
|
|
||||||
|
|
||||||
class VacancyObserver
|
class VacancyObserver
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
@ -27,6 +8,6 @@ class Options extends Model
|
|||||||
{
|
{
|
||||||
public $fillable = [
|
public $fillable = [
|
||||||
'option_name',
|
'option_name',
|
||||||
'option_value',
|
'option_value'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Policies;
|
namespace App\Policies;
|
||||||
|
|
||||||
use App\Application;
|
use App\Application;
|
||||||
|
use Illuminate\Auth\Access\Response;
|
||||||
use App\User;
|
use App\User;
|
||||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||||
use Illuminate\Auth\Access\Response;
|
|
||||||
|
|
||||||
class ApplicationPolicy
|
class ApplicationPolicy
|
||||||
{
|
{
|
||||||
@ -42,7 +23,8 @@ class ApplicationPolicy
|
|||||||
|
|
||||||
public function viewAny(User $user)
|
public function viewAny(User $user)
|
||||||
{
|
{
|
||||||
if ($user->can('applications.view.all')) {
|
if ($user->can('applications.view.all'))
|
||||||
|
{
|
||||||
return Response::allow();
|
return Response::allow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +33,8 @@ class ApplicationPolicy
|
|||||||
|
|
||||||
public function view(User $user, Application $application)
|
public function view(User $user, Application $application)
|
||||||
{
|
{
|
||||||
if ($user->is($application->user) && $user->can('applications.view.own') || $user->can('applications.view.all')) {
|
if ($user->is($application->user) && $user->can('applications.view.own') || $user->can('applications.view.all'))
|
||||||
|
{
|
||||||
return Response::allow();
|
return Response::allow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +48,8 @@ class ApplicationPolicy
|
|||||||
|
|
||||||
public function delete(User $user, Application $application)
|
public function delete(User $user, Application $application)
|
||||||
{
|
{
|
||||||
|
|
||||||
return $user->hasRole('admin');
|
return $user->hasRole('admin');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Policies;
|
namespace App\Policies;
|
||||||
|
|
||||||
use App\Appointment;
|
use App\Appointment;
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Policies;
|
namespace App\Policies;
|
||||||
|
|
||||||
use App\Ban;
|
use App\Ban;
|
||||||
@ -63,13 +44,12 @@ class BanPolicy
|
|||||||
*/
|
*/
|
||||||
public function create(User $user, User $targetUser)
|
public function create(User $user, User $targetUser)
|
||||||
{
|
{
|
||||||
Log::debug('Authorization check started', [
|
Log::debug("Authorization check started", [
|
||||||
'requiredRoles' => 'admin',
|
'requiredRoles' => 'admin',
|
||||||
'hasRequiredRole' => $user->hasRole('admin'),
|
'hasRequiredRole' => $user->hasRole('admin'),
|
||||||
'targetUser' => $targetUser->username,
|
'targetUser' => $targetUser->username,
|
||||||
'isCurrentUser' => Auth::user()->is($user),
|
'isCurrentUser' => Auth::user()->is($user)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $user->hasRole('admin') && $user->isNot($targetUser);
|
return $user->hasRole('admin') && $user->isNot($targetUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user