WIP: Road to 1.0.0 #1

Draft
miguel456 wants to merge 123 commits from develop into master
17 changed files with 85 additions and 126 deletions
Showing only changes of commit 620453c1e4 - Show all commits

View File

@ -29,8 +29,8 @@ class ApiKeyController extends Controller
{
$this->authorize('create', ApiKey::class);
$discriminator = "#" . bin2hex(openssl_random_pseudo_bytes(7));
$secret = bin2hex(openssl_random_pseudo_bytes(32));
$discriminator = "#" . bin2hex(random_bytes(7));
$secret = bin2hex(random_bytes(32));
$key = ApiKey::create([
'name' => $request->keyName,

View File

@ -73,9 +73,9 @@ class BanController extends Controller
]);
event(new UserBannedEvent($user, $ban));
$request->session()->flash('success', 'User banned successfully! Ban ID: #'.$ban->id);
$request->session()->flash('success', 'User suspended successfully! Ban ID: #'.$ban->id);
} else {
$request->session()->flash('error', 'User already banned!');
$request->session()->flash('error', 'User already suspended!');
}
return redirect()->back();
@ -87,9 +87,9 @@ class BanController extends Controller
if (! is_null($user->bans)) {
$user->bans->delete();
$request->session()->flash('success', 'User unbanned successfully!');
$request->session()->flash('success', __('User unsuspended successfully!'));
} else {
$request->session()->flash('error', 'This user isn\'t banned!');
$request->session()->flash('error', __('This user isn\'t suspended!'));
}
return redirect()->back();

View File

@ -45,9 +45,9 @@ class CommentController extends Controller
]);
if ($comment) {
$request->session()->flash('success', 'Comment posted! (:');
$request->session()->flash('success', __('Comment posted! (:'));
} 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();
@ -58,7 +58,7 @@ class CommentController extends Controller
$this->authorize('delete', $comment);
$comment->delete();
$request->session()->flash('success', 'Comment deleted!');
$request->session()->flash('success', __('Comment deleted!'));
return redirect()->back();
}

View File

@ -54,7 +54,7 @@ class ContactController extends Controller
$response = json_decode($verifyrequest->getBody(), true);
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();
}
@ -69,7 +69,7 @@ class ContactController extends Controller
}
}
$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();
}

View File

@ -32,7 +32,7 @@ class DevToolsController extends Controller
protected function isolatedAuthorise()
{
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.'));
}
}
@ -52,9 +52,9 @@ class DevToolsController extends Controller
if (! is_null($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 {
$request->session()->flash('error', 'Application doesn\'t exist!');
$request->session()->flash('error', __('Application doesn\'t exist!'));
}
return redirect()->back();

View File

@ -51,7 +51,7 @@ class FormController extends Controller
if (count($fields) == 2) {
// form is probably empty, since forms with fields will alawys have more than 2 items
$request->session()->flash('error', 'Sorry, but you may not create empty forms.');
$request->session()->flash('error', __('Sorry, but you may not create empty forms.'));
return redirect()->to(route('showForms'));
}
@ -69,7 +69,7 @@ class FormController extends Controller
]
);
$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'));
}
@ -92,9 +92,9 @@ class FormController extends Controller
if ($deletable) {
$form->delete();
$request->session()->flash('success', 'Form deleted successfully.');
$request->session()->flash('success', __('Form deleted successfully.'));
} 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();
@ -135,7 +135,7 @@ class FormController extends Controller
$form->formStructure = $contextValidation->get('structure');
$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 {
$request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages());
}

View File

@ -77,15 +77,15 @@ class OptionsController extends Controller
report($ex);
$errorCond = true;
$request->session()->flash('error', 'An error occurred while trying to save settings: '.$ex->getMessage());
$request->session()->flash('error', __('An error occurred while trying to save settings: :message ', ['message' => $ex->getMessage()]));
}
}
if (! isset($errorCond)) {
$request->session()->flash('success', 'Settings saved successfully!');
$request->session()->flash('success', __('Settings saved successfully!'));
}
} 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.'));
}
return redirect()->back();
@ -103,12 +103,12 @@ class OptionsController extends Controller
if (!is_null($request->gamePref) && in_array($request->gamePref, $supportedGames))
{
Options::changeOption('currentGame', $request->gamePref);
$request->session()->flash('success', 'Updated current game.');
$request->session()->flash('success', __('Updated current game.'));
return redirect()->back();
}
$request->session()->flash('error', 'Unsupported game ' . $request->gamePref . '.');
$request->session()->flash('error', __('Unsupported game :game.', ['game' => $request->gamePref ]));
return redirect()->back();
}

View File

@ -84,7 +84,7 @@ class ProfileController extends Controller
'roles' => $roleList,
]);
} else {
abort(403, 'You cannot view someone else\'s profile.');
abort(403, __('You cannot view someone else\'s profile.'));
}
}
@ -117,7 +117,7 @@ class ProfileController extends Controller
$newProfile = $profile->save();
$request->session()->flash('success', 'Profile settings saved successfully.');
$request->session()->flash('success', __('Profile settings saved successfully.'));
}
return redirect()->back();

View File

@ -1,27 +0,0 @@
<?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;
class ResponseController extends Controller
{
//
}

View File

@ -41,7 +41,7 @@ class SecuritySettingsController extends Controller
Options::changeOption('force2fa', $request->enforce2fa);
Options::changeOption('requireGameLicense', $request->requirePMC);
$request->session()->flash('success', 'Settings saved successfully.');
$request->session()->flash('success', __('Settings saved successfully.'));
return redirect()->back();
}

View File

@ -1,27 +0,0 @@
<?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;
class StaffProfileController extends Controller
{
//
}

View File

@ -70,7 +70,7 @@ class TeamController extends Controller
Auth::user()->teams()->attach($team->id);
$request->session()->flash('success', 'Team successfully created.');
$request->session()->flash('success', __('Team successfully created.'));
return redirect()->back();
}
@ -110,8 +110,7 @@ class TeamController extends Controller
$team->openJoin = $request->joinType;
$team->save();
$request->session()->flash('success', 'Team edited successfully.');
$request->session()->flash('success', __('Team edited successfully.'));
return redirect()->to(route('teams.index'));
}
@ -139,12 +138,12 @@ class TeamController extends Controller
Mail::to($user)->send(new InviteToTeam($invite));
});
$request->session()->flash('success', 'Invite sent! They can now accept or deny it.');
$request->session()->flash('success', __('Invite sent! They can now accept or deny it.'));
} else {
$request->session()->flash('error', 'This user has already been invited.');
$request->session()->flash('error', __('This user has already been invited.'));
}
} else {
$request->session()->flash('error', 'You can\'t invite users to public teams.');
$request->session()->flash('error', __('You can\'t invite users to public teams.'));
}
return redirect()->back();
@ -159,9 +158,9 @@ class TeamController extends Controller
if ($invite && $invite->user->is(Auth::user())) {
Teamwork::acceptInvite($invite);
$request->session()->flash('success', 'Invite accepted! You have now joined '.$invite->team->name.'.');
$request->session()->flash('success', __('Invite accepted! You have now joined :teamName.', ['teamName' => $invite->team->name]));
} else {
$request->session()->flash('error', 'Invalid or expired invite URL.');
$request->session()->flash('error', __('Invalid or expired invite URL.'));
}
break;
@ -172,9 +171,9 @@ class TeamController extends Controller
if ($invite && $invite->user->is(Auth::user())) {
Teamwork::denyInvite($invite);
$request->session()->flash('success', 'Invite denied! Ask for another invite if this isn\'t what you meant.');
$request->session()->flash('success', __('Invite denied! Ask for another invite if this isn\'t what you meant.'));
} else {
$request->session()->flash('error', 'Invalid or expired invite URL.');
$request->session()->flash('error', __('Invalid or expired invite URL.'));
}
break;
@ -195,9 +194,9 @@ class TeamController extends Controller
try {
Auth::user()->switchTeam($team);
$request->session()->flash('success', 'Switched teams! Your team dashboard will now use this context.');
$request->session()->flash('success', __('Switched teams! Your team dashboard will now use this context.'));
} catch (UserNotInTeamException $ex) {
$request->session()->flash('error', 'You can\'t switch to a team you don\'t belong to.');
$request->session()->flash('error', __('You can\'t switch to a team you don\'t belong to.'));
}
return redirect()->back();
@ -220,7 +219,7 @@ class TeamController extends Controller
$team->vacancies()->detach($vacancy->id);
}
$request->session()->flash('success', 'Removed all vacancy associations.');
$request->session()->flash('success', __('Removed all vacancy associations.'));
return redirect()->back();
}
@ -240,7 +239,7 @@ class TeamController extends Controller
$team->vacancies()->attach($requestVacancies);
}
$request->session()->flash('success', 'Assignments changed successfully.');
$request->session()->flash('success', __('Assignments changed successfully.'));
return redirect()->back();
}

View File

@ -140,11 +140,11 @@ class TeamFileController extends Controller
Storage::delete($teamFile->fs_location);
$teamFile->delete();
$request->session()->flash('success', 'File deleted successfully.');
$request->session()->flash('success', __('File deleted successfully.'));
}
catch (\Exception $ex)
{
$request->session()->flash('error', 'There was an error deleting the file: ' . $ex->getMessage());
$request->session()->flash('error', __('There was an error deleting the file: :msg', ['msg' => $ex->getMessage()]));
}
return redirect()->back();

View File

@ -204,9 +204,9 @@ class UserController extends Controller
]);
$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 {
$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();
@ -218,9 +218,9 @@ class UserController extends Controller
if ($request->confirmPrompt == 'DELETE ACCOUNT') {
$user->forceDelete();
$request->session()->flash('success', 'User deleted successfully. PII has been erased.');
$request->session()->flash('success', __('User deleted successfully.'));
} else {
$request->session()->flash('error', 'Wrong confirmation text! Try again.');
$request->session()->flash('error', __('Wrong confirmation text! Try again.'));
}
return redirect()->route('registeredPlayerList');
@ -287,9 +287,9 @@ class UserController extends Controller
$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 {
$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);
}
@ -306,7 +306,7 @@ class UserController extends Controller
$request->user()->twofa_secret = null;
$request->user()->save();
$request->session()->flash('success', 'Two-factor authentication disabled.');
$request->session()->flash('success', __('Two-factor authentication disabled.'));
return redirect()->back();
}
@ -317,7 +317,7 @@ class UserController extends Controller
// TODO: move logic to policy
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();
}
@ -331,7 +331,7 @@ class UserController extends Controller
}
Log::info('User '.$user->name.' has just been demoted.');
$request->session()->flash('success', 'User terminated successfully.');
$request->session()->flash('success', __('User terminated successfully.'));
//TODO: Dispatch event
return redirect()->back();

View File

@ -21,6 +21,7 @@
namespace App\Http\Controllers;
use App\Facades\JSON;
use App\Form;
use App\Http\Requests\VacancyEditRequest;
use App\Http\Requests\VacancyRequest;
@ -45,7 +46,11 @@ class VacancyController extends Controller
public function store(VacancyRequest $request)
{
$messageIsError = false;
$this->authorize('create', Vacancy::class);
$form = Form::find($request->vacancyFormID);
if (! is_null($form)) {
@ -67,12 +72,16 @@ class VacancyController extends Controller
]);
$request->session()->flash('success', 'Vacancy successfully opened. It will now show in the home page.');
$message = __('Vacancy successfully opened. It will now show in the home page.');
} else {
$request->session()->flash('error', 'You cannot create a vacancy without a valid form.');
$message = __('You cannot create a vacancy without a valid form.');
$messageIsError = true;
}
return redirect()->back();
return redirect()
->back()
->with(($messageIsError) ? 'error' : 'success', $message);
}
public function updatePositionAvailability(Request $request, $status, Vacancy $vacancy)
@ -85,13 +94,13 @@ class VacancyController extends Controller
switch ($status) {
case 'open':
$vacancy->open();
$message = 'Position successfully opened!';
$message = __('Position successfully opened!');
break;
case 'close':
$vacancy->close();
$message = 'Position successfully closed!';
$message = __('Position successfully closed!');
foreach (User::all() as $user) {
if ($user->isStaffMember()) {
@ -101,18 +110,19 @@ class VacancyController extends Controller
break;
default:
$message = "Please do not tamper with the button's URLs. To report a bug, please contact an administrator.";
$message = __("Please do not tamper with the URLs. To report a bug, please contact an administrator.");
$type = 'error';
}
} 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';
}
$request->session()->flash($type, $message);
return redirect()
->back()
->with($type, $message);
return redirect()->back();
}
public function edit(Request $request, Vacancy $vacancy)
@ -127,14 +137,14 @@ class VacancyController extends Controller
{
$this->authorize('update', $vacancy);
$vacancy->vacancyFullDescription = $request->vacancyFullDescription;
$vacancy->vacancyFullDescription = $request->vacancyFullDescription;
$vacancy->vacancyDescription = $request->vacancyDescription;
$vacancy->vacancyCount = $request->vacancyCount;
$vacancy->save();
$request->session()->flash('success', 'Vacancy successfully updated.');
return redirect()->back();
return redirect()
->back()
->with('success', __('Vacancy successfully updated.'));
}
}

View File

@ -42,7 +42,7 @@ trait ReceivesAccountTokens
$user->delete();
Auth::logout();
$request->session()->flash('success', 'Please check your email to finish deleting your account.');
$request->session()->flash('success', __('Please check your email to finish deleting your account.'));
return redirect()->to('/');
}
@ -68,7 +68,7 @@ trait ReceivesAccountTokens
$user->forceDelete();
$request->session()->flash('success', 'Account permanently deleted. Thank you for using our service.');
$request->session()->flash('success', __('Account permanently deleted. Thank you for using our service.'));
return redirect()->to('/');
}
@ -79,7 +79,7 @@ trait ReceivesAccountTokens
if ($user->verifyAccountToken($token, 'cancelToken')) {
$user->restore();
$request->session()->flash('success', 'Account deletion cancelled! You may now login.');
$request->session()->flash('success', __('Account deletion cancelled! You may now login.'));
return redirect()->to(route('login'));
}
@ -88,7 +88,7 @@ trait ReceivesAccountTokens
default:
abort(404, 'The page you were trying to access may not exist or may be expired.');
abort(404, __('The page you were trying to access may not exist or may be expired.'));
}
}
}

View File

@ -47,4 +47,8 @@ Route::middleware(['api'])->group(function (){
});
Route::group(['prefix' => 'vacancies'], function () {
});
});