forked from miguel456/rbrecruiter
Compare commits
238 Commits
0.1.0
...
analysis-a
Author | SHA1 | Date | |
---|---|---|---|
773ec570d9 | |||
53c23f3698 | |||
f1db159eee | |||
0d14a65ee5 | |||
2942157603 | |||
11f3fb90d0 | |||
937a0206a5 | |||
3598a32ecf | |||
ac8b303e2c | |||
e93abd2ab7 | |||
20ab381076 | |||
e566e40404 | |||
b0a935b8b3 | |||
0dfb68dba2 | |||
24303052ad | |||
178bc31a6e | |||
98e557a840 | |||
95bf7c239e | |||
4d2595dd39 | |||
4e81a41210 | |||
1319ce6b86 | |||
bea83b650c | |||
675cc3c329 | |||
e8119b763c | |||
04838048ce | |||
87f8e63b24 | |||
7292aab4b7 | |||
9f3780d844 | |||
e37b38f2d9 | |||
c83e720a6d | |||
9241a83844 | |||
c6685331a8 | |||
9da9b8e6fc | |||
bb019f71e2 | |||
0cde3444ce | |||
b61fb5642e | |||
f7614916bf | |||
2ad1548cd6 | |||
43579c8fc9 | |||
0c9cea5c05 | |||
4371dd971c | |||
c57ace1ad9 | |||
c35b37d9b3 | |||
f25c9f7bc7 | |||
25cebeefab | |||
8b47dbe2e0 | |||
290dbe99b6 | |||
d7b506ec52 | |||
d41d94b934 | |||
b571d72eaf | |||
0c1f6f75eb | |||
5ea9e11a62 | |||
fbd1e83306 | |||
50ed47964c | |||
58d6a8ef1f | |||
d988b9a5cb | |||
eeae03dec5 | |||
c374100eed | |||
01e3a9edce | |||
d93170b555 | |||
8e85e08171 | |||
de3dba3627 | |||
f7a18816bc | |||
369185c4ed | |||
5ee79880d5 | |||
75d7181bca | |||
3fe3df7357 | |||
7e58c3af6b | |||
5ca155ba42 | |||
7c7c20d5b2 | |||
fdb508fd5a | |||
cbe660f4ad | |||
6e34b6b8fa | |||
60874c046f | |||
e9dd1567b8 | |||
a95c9518b3 | |||
af96d193a4 | |||
48054f0837 | |||
9b5e35b241 | |||
4c7783f366 | |||
af2c23a73c | |||
af17bbe468 | |||
17f61f0d6b | |||
a5aef7deb7 | |||
f32c4dc68c | |||
687316d77a | |||
ff70c21283 | |||
727c14d0c2 | |||
6b7d2db612 | |||
d743554df6 | |||
fd8bf4f0f2 | |||
bd530696d2 | |||
3040afd730 | |||
e7d2c548c0 | |||
f001a16d4d | |||
d8dbb1a0a2 | |||
4e1b4f5afd | |||
81c0b65404 | |||
a10f3f9c96 | |||
326e0f8c7c | |||
a0192cdb02 | |||
8f45563b24 | |||
004e9edcb0 | |||
fafc9dca87 | |||
800d205c74 | |||
3cd7292c36 | |||
36db8a1337 | |||
bcd11c462a | |||
6703ac89c1 | |||
fda34ad8bf | |||
2cde1cdbbe | |||
0bca7619f7 | |||
d223515d19 | |||
93fb7a8432 | |||
6bf0d9f373 | |||
db5d150758 | |||
348b1a37d0 | |||
86bf02bb42 | |||
6c45573fbe | |||
910863bdea | |||
884ff74f42 | |||
4f1935fbf2 | |||
3a53f3bbc2 | |||
6c08e839d6 | |||
362ce6c866 | |||
d336354482 | |||
88cf53c53d | |||
a5568be339 | |||
d393a8cedc | |||
62d5f68279 | |||
5c068a325d | |||
15c02c1de1 | |||
3782f79b51 | |||
0c53757912 | |||
6db69f997d | |||
edb2e4b2d6 | |||
baac37e967 | |||
5952ed9248 | |||
356483ef7b | |||
b80e168dfb | |||
9b469c434b | |||
ca3a06f248 | |||
1e2f331778 | |||
4a09fa581d | |||
c58b5b56d7 | |||
bf5d4058ad | |||
f871e14307 | |||
1e78a8e6d9 | |||
17fb0e236f | |||
27b1f3170b | |||
00cc36246f | |||
41e3e817a2 | |||
2afea88846 | |||
ea96cbc1f5 | |||
2996e66c8b | |||
a32af7c464 | |||
cd874c5f58 | |||
42de40e320 | |||
faa3a65e2b | |||
ba3a139d1c | |||
25ddf81118 | |||
9431eb5036 | |||
a3071dccf9 | |||
b0cbf65cfc | |||
6be5e241d4 | |||
d6c49a5cf0 | |||
075617fd32 | |||
da73c91b4a | |||
ca82f5882d | |||
88c36dd3f8 | |||
535a2c3973 | |||
ad5c3404cc | |||
64d418c590 | |||
62b063ee63 | |||
2c0c404d73 | |||
168f08bd96 | |||
94d08f1886 | |||
0cf6208577 | |||
9255a6c88d | |||
098205a969 | |||
bf426e3bdd | |||
02059bbcb0 | |||
91627decbe | |||
2763f777ab | |||
d392c0593f | |||
5f1f92a9ce | |||
9e2d571298 | |||
e16be5dc46 | |||
1a04880489 | |||
3693ce3431 | |||
4a766620ff | |||
bca6020ab0 | |||
1f50faaea7 | |||
e978a5417b | |||
4dc412e53c | |||
bd0664ce0d | |||
4b390ea536 | |||
035c9399a6 | |||
bbe3001157 | |||
d1f4be124c | |||
0f126886f5 | |||
4deb882d23 | |||
635f8593d3 | |||
c3a6b16a13 | |||
fb4d832489 | |||
4456d19c1f | |||
c7fd8989f9 | |||
fb422c1ef7 | |||
a42df354c7 | |||
173dc57aa7 | |||
cb2b45b55f | |||
a3e727f1f1 | |||
669c3c87e6 | |||
96298cd38c | |||
00f37d3f7e | |||
653641f4e8 | |||
d121119706 | |||
1c08cd9057 | |||
1bc63725c9 | |||
c7caf3a67c | |||
7c7d4a306c | |||
016ce1fbf6 | |||
f673ef8222 | |||
2bf8c8e90c | |||
d111864bea | |||
4dbf86a328 | |||
291c98cd0e | |||
119ea1d8ec | |||
0282a6a7c9 | |||
8ed2eb5027 | |||
|
61034ccae9 | ||
ed95f02e00 | |||
c58c46eda8 | |||
91c408fb4f | |||
599d742e96 | |||
50692a8abf | |||
664bdcf45e | |||
9ec2f9edce |
18
.env.example
18
.env.example
@@ -3,6 +3,9 @@ APP_ENV=local
|
|||||||
APP_KEY=
|
APP_KEY=
|
||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_URL=http://localhost
|
APP_URL=http://localhost
|
||||||
|
APP_LOGO="https://www.raspberrypi.org/app/uploads/2020/05/Raspberry-Pi-OS-downloads-image-150x150-1.png"
|
||||||
|
APP_SITEHOMEPAGE=""
|
||||||
|
# This can be your main homepage, other than this site itself
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
LOG_CHANNEL=stack
|
||||||
|
|
||||||
@@ -18,8 +21,17 @@ RECAPTCHA_PRIVATE_KEY=
|
|||||||
RECAPTCHA_VERIFY_URL="https://www.google.com/recaptcha/api/siteverify"
|
RECAPTCHA_VERIFY_URL="https://www.google.com/recaptcha/api/siteverify"
|
||||||
# WARNING: Your contact form will be useless if you change this value. Only change this URL if Google updates it.
|
# WARNING: Your contact form will be useless if you change this value. Only change this URL if Google updates it.
|
||||||
|
|
||||||
|
MOJANG_STATUS_URL="https://status.mojang.com/check"
|
||||||
|
MOJANG_API_URL="https://api.mojang.com"
|
||||||
|
|
||||||
IPGEO_API_KEY=""
|
IPGEO_API_KEY=""
|
||||||
IPGEO_API_URL=""
|
IPGEO_API_URL="https://api.ipgeolocation.io/ipgeo"
|
||||||
|
|
||||||
|
ARCANEDEV_LOGVIEWER_MIDDLEWARE=web,auth,can:admin.maintenance.logs.view
|
||||||
|
|
||||||
|
RELEASE=staffmanagement@0.6.1
|
||||||
|
|
||||||
|
SLACK_INTEGRATION_WEBHOOK=
|
||||||
|
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
@@ -53,4 +65,8 @@ PUSHER_APP_CLUSTER=mt1
|
|||||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||||
|
|
||||||
|
# Mostly for developers, but with Papertrail, you can easily see what the app's users are doing without relying on
|
||||||
|
# the internal log viewer.
|
||||||
SENTRY_LARAVEL_DSN=
|
SENTRY_LARAVEL_DSN=
|
||||||
|
PAPERTRAIL_URL=
|
||||||
|
PAPERTRAIL_PORT
|
||||||
|
42
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
42
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: "[BUG] - Short description of what went wrong"
|
||||||
|
labels: bug, help wanted
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**Steps to reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Desktop (please complete the following information):**
|
||||||
|
- OS: [e.g. iOS]
|
||||||
|
- Browser [e.g. chrome, safari]
|
||||||
|
- Version [e.g. 22]
|
||||||
|
|
||||||
|
**Smartphone (please complete the following information):**
|
||||||
|
- Device: [e.g. iPhone6]
|
||||||
|
- OS: [e.g. iOS8.1]
|
||||||
|
- Browser [e.g. stock browser, safari]
|
||||||
|
- Version [e.g. 22]
|
||||||
|
|
||||||
|
**PHP Version: **
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
|
|
||||||
|
**Log files: attach any log files from the storage/logs directory**.
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@
|
|||||||
/public/storage
|
/public/storage
|
||||||
/storage/*.key
|
/storage/*.key
|
||||||
/vendor
|
/vendor
|
||||||
|
/tools
|
||||||
.env
|
.env
|
||||||
.env.backup
|
.env.backup
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
2
.idea/hrm-mcserver.iml
generated
2
.idea/hrm-mcserver.iml
generated
@@ -39,7 +39,9 @@
|
|||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/ui" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/ui" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/league/commonmark" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/league/commonmark" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/league/flysystem" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/league/flysystem" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/vendor/league/mime-type-detection" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/maximebf/debugbar" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/maximebf/debugbar" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/vendor/mcamara/laravel-localization" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/mockery/mockery" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/mockery/mockery" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/monolog/monolog" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/monolog/monolog" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/myclabs/deep-copy" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/myclabs/deep-copy" />
|
||||||
|
14
.idea/php.xml
generated
14
.idea/php.xml
generated
@@ -127,6 +127,20 @@
|
|||||||
<path value="$PROJECT_DIR$/vendor/symfony/string" />
|
<path value="$PROJECT_DIR$/vendor/symfony/string" />
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-grapheme" />
|
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-grapheme" />
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php80" />
|
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php80" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/bacon/bacon-qr-code" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/dasprid/enum" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/geo-sot/laravel-env-editor" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/laravel/slack-notification-channel" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php70" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/pragmarx/google2fa-laravel" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/pragmarx/google2fa" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/pragmarx/google2fa-qrcode" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/arcanedev/log-viewer" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/arcanedev/support" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/paragonie/constant_time_encoding" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/graham-campbell/markdown" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/league/mime-type-detection" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/mcamara/laravel-localization" />
|
||||||
</include_path>
|
</include_path>
|
||||||
</component>
|
</component>
|
||||||
<component name="PhpProjectSharedConfiguration" php_language_level="7.2" />
|
<component name="PhpProjectSharedConfiguration" php_language_level="7.2" />
|
||||||
|
5
.phive/phars.xml
Normal file
5
.phive/phars.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phive xmlns="https://phar.io/phive">
|
||||||
|
<phar name="phpunit" version="^9.2.5" installed="9.2.5" location="./tools/phpunit" copy="false"/>
|
||||||
|
<phar name="php-cs-fixer" version="^2.16.4" installed="2.16.4" location="./tools/php-cs-fixer" copy="false"/>
|
||||||
|
</phive>
|
76
CODE_OF_CONDUCT.md
Normal file
76
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to making participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||||
|
level of experience, education, socio-economic status, nationality, personal
|
||||||
|
appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces
|
||||||
|
when an individual is representing the project or its community. Examples of
|
||||||
|
representing a project or community include using an official project e-mail
|
||||||
|
address, posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event. Representation of a project may be
|
||||||
|
further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team at support@spacejewel-hosting.com. All
|
||||||
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||||
|
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see
|
||||||
|
https://www.contributor-covenant.org/faq
|
29
CONTRIBUTING.md
Normal file
29
CONTRIBUTING.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Thank you for contributing!
|
||||||
|
|
||||||
|
Read this file carefully before contributing to the project. It's important that everyone follows these rules to ensure smooth contribution.
|
||||||
|
|
||||||
|
## General workflow
|
||||||
|
|
||||||
|
Since the project is under version 1.0.0, the master branch can be quite unstable, and even unusable. For this reason, I recommend you stick to the published
|
||||||
|
releases, unless you intend on helping out with the project.
|
||||||
|
|
||||||
|
New features are commited directly to the ``master`` branch, while translations are commited to a special service branch, merged onto ``translate``, tested, and
|
||||||
|
merged back to master. Above version 1.0.0, new features should follow the same procedure as translations.
|
||||||
|
|
||||||
|
## Before commiting
|
||||||
|
|
||||||
|
Before commiting, make sure your code adheres to the Laravel coding guidelines, as well as PSR-4. I'll personally review and merge each PR.
|
||||||
|
Thank you for your interest!
|
||||||
|
|
||||||
|
|
||||||
|
# Bug reports
|
||||||
|
|
||||||
|
As always, bug reports should stick to the bug report template. GitHub makes this easy for you by letting you choose which issue template you'd like to use
|
||||||
|
before reporting an isuse. This helps everyone stay in the same page.
|
||||||
|
|
||||||
|
Issues published without a template might take longer to be resolved, or may be ignored and marked ``wontfix``.
|
||||||
|
|
||||||
|
|
||||||
|
# Licensing
|
||||||
|
|
||||||
|
Any contributions you make will be under the GNU GPL v3 license, which is the license that covers this project.
|
125
README.md
125
README.md
@@ -1,79 +1,84 @@
|
|||||||
<p align="center"><img src="https://res.cloudinary.com/dtfbvvkyp/image/upload/v1566331377/laravel-logolockup-cmyk-red.svg" width="400"></p>
|
|
||||||
|
|
||||||
<p align="center">
|
# RB Recruiter v 0.6.2 [](https://crowdin.com/project/raspberry-staff-manager)
|
||||||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
## The quick and pain-free form management solution for communities
|
||||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
|
|
||||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
|
|
||||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
## About Laravel
|
Have you ever gotten tired of managing your Minecraft server/network's applications through Discord (or anything else) and having to scroll through hundreds of new messages just to find that one applicant's username?
|
||||||
|
|
||||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
|
||||||
|
|
||||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
Wish you had a better application managemet strategy? Well, then Raspberry Teams is for you! It was originally designed and developed for internal use for a gameserver network, but sharing is caring!
|
||||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
|
||||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
|
||||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
|
||||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
|
||||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
|
||||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
|
||||||
|
|
||||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
|
||||||
|
|
||||||
## Learning Laravel
|
# Features (not exhaustive)
|
||||||
|
- Beautiful (customizable in future releases) landing page for your application management center; It displays all available staff ranks
|
||||||
|
- Contact form on landing page for those un-registerd users
|
||||||
|
- User registration/authentication system; Users will be sent to the authentication flow to complete their application, if not logged in
|
||||||
|
- Candidate tracking system - Applicants will be tracked from start to finish.
|
||||||
|
- Peer approval system - Have all your staff members vote on applications and decide whether they should be accepted (this is overridable)
|
||||||
|
- Interview scheduling (simple) - Schedule interviews with your candidates and automatically notify them!
|
||||||
|
- Interview notes: Every staff member is able to add and edit interview notes (how the interview went, etc)
|
||||||
|
- Application comments: Finally no more having to go to a private Discord channel just to comment on a single application. Comments are organised neatly for every application! This should help in the decision process of voting for an application.
|
||||||
|
- User profiles - Fill out your profile for others to better find you
|
||||||
|
- User directory - Public profile directory for everyone
|
||||||
|
- Staff rank management - Add/remove ranks on demand, that users will be able to apply to
|
||||||
|
- Simple form builder - Create your application forms easily!
|
||||||
|
- Termination - Has a staff member met their untimely demise? Terminate them. This will strip their permissions and roles.
|
||||||
|
- Controllable permissions - Every user has permissions! Control who has access to what (You can skip the application process and add staff members directly here).
|
||||||
|
- Ban system - Having trouble with pesky spammers? Ban them! This will publicly shame their profile and keep them from signing up or logging in.
|
||||||
|
- Notifications: Notifies slack and email primarily
|
||||||
|
|
||||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
And many more features!
|
||||||
|
|
||||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
# Roadmap
|
||||||
|
|
||||||
## Laravel Sponsors
|
Many other features are currently planned for this app, such as:
|
||||||
|
- Discord role management (approved applicants)
|
||||||
|
- Luckperms/PEX integration - For now, you'll have to promote users manually in-game
|
||||||
|
- Flexibility - This app is built on a flexible concept! It will be able to be used for other purposes other than MC staff members.
|
||||||
|
- Customisable front page (**priority**)
|
||||||
|
- Auto provisioning - Sign up on a website and get your instance of Raspberry Teams up and running in no time
|
||||||
|
- Suggestions accepted!
|
||||||
|
|
||||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
|
||||||
|
|
||||||
- **[Vehikl](https://vehikl.com/)**
|
# Technical overview
|
||||||
- **[Tighten Co.](https://tighten.co)**
|
|
||||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
|
||||||
- **[64 Robots](https://64robots.com)**
|
|
||||||
- **[Cubet Techno Labs](https://cubettech.com)**
|
|
||||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
|
||||||
- **[British Software Development](https://www.britishsoftware.co)**
|
|
||||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
|
||||||
- **[DevSquad](https://devsquad.com)**
|
|
||||||
- [UserInsights](https://userinsights.com)
|
|
||||||
- [Fragrantica](https://www.fragrantica.com)
|
|
||||||
- [SOFTonSOFA](https://softonsofa.com/)
|
|
||||||
- [User10](https://user10.com)
|
|
||||||
- [Soumettre.fr](https://soumettre.fr/)
|
|
||||||
- [CodeBrisk](https://codebrisk.com)
|
|
||||||
- [1Forge](https://1forge.com)
|
|
||||||
- [TECPRESSO](https://tecpresso.co.jp/)
|
|
||||||
- [Runtime Converter](http://runtimeconverter.com/)
|
|
||||||
- [WebL'Agence](https://weblagence.com/)
|
|
||||||
- [Invoice Ninja](https://www.invoiceninja.com)
|
|
||||||
- [iMi digital](https://www.imi-digital.de/)
|
|
||||||
- [Earthlink](https://www.earthlink.ro/)
|
|
||||||
- [Steadfast Collective](https://steadfastcollective.com/)
|
|
||||||
- [We Are The Robots Inc.](https://watr.mx/)
|
|
||||||
- [Understand.io](https://www.understand.io/)
|
|
||||||
- [Abdel Elrafa](https://abdelelrafa.com)
|
|
||||||
- [Hyper Host](https://hyper.host)
|
|
||||||
- [Appoly](https://www.appoly.co.uk)
|
|
||||||
- [OP.GG](https://op.gg)
|
|
||||||
- [云软科技](http://www.yunruan.ltd/)
|
|
||||||
|
|
||||||
## Contributing
|
Tech stack:
|
||||||
|
- [Laravel 7](https://laravel.com/)
|
||||||
|
- Eloquent ORM
|
||||||
|
- AdminLTE / Bootstrap 4
|
||||||
|
- jQuery / Plain Javascript
|
||||||
|
- vueJS (in the future)
|
||||||
|
|
||||||
|
# Stability
|
||||||
|
|
||||||
|
Currently, the ``master`` branch is highly unstable, since it's under active development. Expect it to break with each commit. Even though I make an effort to make sure each commit is good to go before pushing, things might still break unexpectedly, and you may find a lot of bugs (which you should report).
|
||||||
|
|
||||||
|
Every released version is currently pre-release. If you really want to run this before version ``1.0.0`` comes out, always stay on the latest version, as those will always be tested before release, ensuring less chaos.
|
||||||
|
|
||||||
|
*Note: This application is NOT production ready! It won't be until the first stable release comes out, which might take a bit longer.
|
||||||
|
|
||||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
# Operating System Requirements
|
||||||
|
|
||||||
## Code of Conduct
|
Currently, this application is only supported on Linux environments (Ubuntu 20.04 or derivatives are recommended).
|
||||||
|
|
||||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
# Software Requirements
|
||||||
|
- ``composer`` (min version: 1.8.4)
|
||||||
|
- ``npm`` (tested w/ v 5.8.0)
|
||||||
|
- ``php`` (required PHP 7 or newer - lower versions unsupported!)
|
||||||
|
|
||||||
## Security Vulnerabilities
|
# PHP Extension Requirements
|
||||||
|
|
||||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
- JSON
|
||||||
|
- Curl (highly recommended)
|
||||||
|
- Image Magick (imagick) for 2FA support
|
||||||
|
|
||||||
## License
|
# Installation
|
||||||
|
|
||||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
Make sure all prerequisites are installed. Afterwards, clone this repository, make ``install.sh``executable and run it.
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
Configuration is currently done via the installer. Alternatively, you may also edit the ``.env`` file directly.
|
||||||
|
This process will be moved to the browser later.
|
||||||
|
|
||||||
|
# Bug reports
|
||||||
|
|
||||||
|
Please report any bugs you find to the issues section here! It'd be immensely helpful. PRs are also accepted.
|
||||||
|
19
SECURITY.md
Normal file
19
SECURITY.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
The following versions are currently supported:
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
| ------- | ------------------ |
|
||||||
|
| 0.1.x | :x: |
|
||||||
|
| 0.5.x | :x: |
|
||||||
|
| 0.6.x | :white_check_mark: |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
To securely report a vulnerability, you may send me an email directly containing the details of said vulnerability: ``me@nogueira.codes``.
|
||||||
|
|
||||||
|
You may optionally encrypt your message with my [public PGP key](http://pool.sks-keyservers.net/pks/lookup?op=get&search=0x48DF709E7405702B).
|
||||||
|
|
||||||
|
Use this free [online encryption tool](https://www.igolder.com/pgp/encryption/) if you don't know how to use PGP on your desktop.
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -10,13 +29,10 @@ 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');
|
||||||
@@ -37,7 +53,6 @@ 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');
|
||||||
@@ -46,8 +61,7 @@ class Application extends Model
|
|||||||
public function setStatus($status)
|
public function setStatus($status)
|
||||||
{
|
{
|
||||||
return $this->update([
|
return $this->update([
|
||||||
'applicationStatus' => $status
|
'applicationStatus' => $status,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -7,23 +26,25 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
class Appointment extends Model
|
class Appointment extends Model
|
||||||
{
|
{
|
||||||
public $fillable = [
|
public $fillable = [
|
||||||
'appointmentDescription',
|
'appointmentDescription',
|
||||||
'appointmentDate',
|
'appointmentDate',
|
||||||
'applicationID',
|
'applicationID',
|
||||||
'appointmentStatus',
|
'appointmentStatus',
|
||||||
'appointmentLocation'
|
'appointmentLocation',
|
||||||
|
'meetingNotes',
|
||||||
|
'userAccepted',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function application()
|
public function application()
|
||||||
{
|
{
|
||||||
// FIXME: Possible bug here, where laravel looks for the wrong column in the applications table.
|
// FIXME: Possible bug here, where laravel looks for the wrong column in the applications table.
|
||||||
return $this->belongsTo('App\Application', 'id', 'applicationID');
|
return $this->belongsTo('App\Application', 'id', 'applicationID');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setStatus($status)
|
public function setStatus($status)
|
||||||
{
|
{
|
||||||
$this->update([
|
$this->update([
|
||||||
'appointmentStatus' => $status
|
'appointmentStatus' => $status,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
31
app/Ban.php
31
app/Ban.php
@@ -1,25 +1,46 @@
|
|||||||
<?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 = [
|
||||||
|
'bannedUntil',
|
||||||
|
];
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\User', 'userID', 'id');
|
return $this->belongsTo('App\User', 'userID', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +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;
|
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()
|
||||||
@@ -22,5 +40,4 @@ class Comment extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo('App\User', 'authorID', 'id');
|
return $this->belongsTo('App\User', 'authorID', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -43,28 +62,23 @@ 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;
|
||||||
@@ -74,7 +88,7 @@ class CountVotes extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info('Total votes for application ID ' . $application->id . ': ' . $voteCount);
|
$this->info('Total votes for application ID '.$application->id.': '.$voteCount);
|
||||||
$this->info('Calculating criteria...');
|
$this->info('Calculating criteria...');
|
||||||
$negativeVotePercent = floor(($negativeVotes / $voteCount) * 100);
|
$negativeVotePercent = floor(($negativeVotes / $voteCount) * 100);
|
||||||
$positiveVotePercent = floor(($positiveVotes / $voteCount) * 100);
|
$positiveVotePercent = floor(($positiveVotes / $voteCount) * 100);
|
||||||
@@ -83,54 +97,43 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
146
app/Console/Commands/Install.php
Normal file
146
app/Console/Commands/Install.php
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class Install extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'application:install {-u|--unattended: Install non-interactively (currently unused: WIP)}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Installs the application and prepares for production use.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$basePath = base_path();
|
||||||
|
if (Storage::disk('local')->missing('INSTALLED')) {
|
||||||
|
$this->info('[!! Welcome to Rasberry Teams !!]');
|
||||||
|
$this->info('>> Installing...');
|
||||||
|
$this->call('down', [
|
||||||
|
'--message' => 'Down for maintenance. We\'ll be right back!',
|
||||||
|
]);
|
||||||
|
|
||||||
|
copy($basePath.'/.env.example', $basePath.'/.env');
|
||||||
|
$this->call('key:generate');
|
||||||
|
|
||||||
|
$this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.');
|
||||||
|
|
||||||
|
$npmOut = 0;
|
||||||
|
$npmMessages = [];
|
||||||
|
|
||||||
|
$npmBuildOut = 0;
|
||||||
|
$npmBuildMessages = [];
|
||||||
|
|
||||||
|
exec('cd '.$basePath.' && npm install --silent', $npmBuildOut, $npmOut);
|
||||||
|
exec('cd '.$basePath.'&& npm run dev --silent', $npmBuildMessages, $npmBuildOut);
|
||||||
|
|
||||||
|
if ($npmOut !== 0 && $npmBuildOut !== 0) {
|
||||||
|
$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.');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings = [];
|
||||||
|
|
||||||
|
$this->info('>> Configuring application - We\'re going to ask a few questions here!');
|
||||||
|
do {
|
||||||
|
$this->info('== Database Settings (1/6) ==');
|
||||||
|
|
||||||
|
$settings['DB_USERNAME'] = $this->ask('Database username');
|
||||||
|
$settings['DB_PASSWORD'] = $this->secret('Database password (Input won\'t be seen)');
|
||||||
|
$settings['DB_DATABASE'] = $this->ask('Database name');
|
||||||
|
$settings['DB_PORT'] = $this->ask('Database port');
|
||||||
|
$settings['DB_HOST'] = $this->ask('Database hostname');
|
||||||
|
|
||||||
|
$this->info('== Antispam Settings (2/6) (Recaptcha v2) ==');
|
||||||
|
$settings['RECAPTCHA_SITE_KEY'] = $this->ask('Site key');
|
||||||
|
$settings['RECAPTCHA_PRIVATE_KEY'] = $this->ask('Private site key');
|
||||||
|
|
||||||
|
$this->info('== IP Geolocation Settings (3/6) (refer to README.md) ==');
|
||||||
|
$settings['IPGEO_API_KEY'] = $this->ask('API Key');
|
||||||
|
|
||||||
|
$this->info('== Notification Settings (4/6) (Email) ==');
|
||||||
|
$settings['MAIL_USERNAME'] = $this->ask('SMTP Username');
|
||||||
|
$settings['MAIL_PASSWORD'] = $this->secret('SMTP Password (Input won\'t be seen)');
|
||||||
|
$settings['MAIL_PORT'] = $this->ask('SMTP Server Port');
|
||||||
|
$settings['MAIL_HOST'] = $this->ask('SMTP Server Hostname');
|
||||||
|
$settings['MAIL_FROM'] = $this->ask('E-mail address to send from: ');
|
||||||
|
|
||||||
|
$this->info('== Notification Settings (5/6) (Slack) ==');
|
||||||
|
$settings['SLACK_INTEGRATION_WEBHOOK'] = $this->ask('Integration webhook URL');
|
||||||
|
|
||||||
|
$this->info('== Web Settings (6/6) ==');
|
||||||
|
$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_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.'));
|
||||||
|
|
||||||
|
foreach ($settings as $keyname => $value) {
|
||||||
|
$this->call('environment:modify', [
|
||||||
|
'key' => $keyname,
|
||||||
|
'value' => $value,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info('>> Saved configuration settings!');
|
||||||
|
$this->info('>> Preparing database...');
|
||||||
|
|
||||||
|
$this->callSilent('config:cache');
|
||||||
|
$this->call('migrate');
|
||||||
|
$this->call('db:seed');
|
||||||
|
|
||||||
|
touch($basePath.'/INSTALLED');
|
||||||
|
|
||||||
|
$this->call('up');
|
||||||
|
$this->info('>> All done! Visit '.$basePath.' to start using your brand new installation of Raspberry Teams!');
|
||||||
|
} else {
|
||||||
|
$this->error('[!] The application is already installed!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
71
app/Console/Commands/SetEnv.php
Normal file
71
app/Console/Commands/SetEnv.php
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use GeoSot\EnvEditor\Facades\EnvEditor;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class SetEnv extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'environment:modify {key : Key name} {value : New value}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Permanently modifies an environment variable on the .env file for later use.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$path = base_path('/.env');
|
||||||
|
$key = $this->argument('key');
|
||||||
|
$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.');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,10 +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\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,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -7,7 +26,6 @@ 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
|
||||||
@@ -15,28 +33,18 @@ class IP
|
|||||||
*/
|
*/
|
||||||
public function lookup(string $IP): object
|
public function lookup(string $IP): object
|
||||||
{
|
{
|
||||||
|
$params = [
|
||||||
if (empty($IP))
|
|
||||||
{
|
|
||||||
throw new LogicException(__METHOD__ . 'is missing parameter IP!');
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
'apiKey' => config('general.keys.ipapi.apikey'),
|
|
||||||
'ip' => $IP
|
|
||||||
];
|
|
||||||
|
|
||||||
// TODO: Maybe unwrap this? Methods are chained here
|
|
||||||
|
|
||||||
return json_decode(Cache::remember($IP, 3600, function() use ($IP)
|
|
||||||
{
|
|
||||||
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();
|
];
|
||||||
}));
|
|
||||||
|
|
||||||
|
// TODO: Maybe unwrap this? Methods are chained here
|
||||||
|
|
||||||
|
return json_decode(Cache::remember($IP, 3600, function () use ($IP) {
|
||||||
|
return Http::get(config('general.urls.ipapi.ipcheck'), [
|
||||||
|
'apiKey' => config('general.keys.ipapi.apikey'),
|
||||||
|
'ip' => $IP,
|
||||||
|
])->body();
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,28 @@
|
|||||||
<?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;
|
||||||
|
|
||||||
@@ -26,6 +41,4 @@ class ApplicationApprovedEvent
|
|||||||
{
|
{
|
||||||
$this->application = $application;
|
$this->application = $application;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,28 @@
|
|||||||
<?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;
|
||||||
|
|
||||||
@@ -26,5 +41,4 @@ class ApplicationDeniedEvent
|
|||||||
{
|
{
|
||||||
$this->application = $application;
|
$this->application = $application;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,28 @@
|
|||||||
<?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,23 +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\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use Illuminate\Broadcasting\Channel;
|
use App\Ban;
|
||||||
|
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;
|
||||||
@@ -32,5 +45,4 @@ class UserBannedEvent
|
|||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->ban = $ban;
|
$this->ban = $ban;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
|
32
app/Facades/ContextAwareValidation.php
Normal file
32
app/Facades/ContextAwareValidation.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class ContextAwareValidation extends Facade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'contextAwareValidator';
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
|
32
app/Facades/Options.php
Normal file
32
app/Facades/Options.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class Options extends Facade
|
||||||
|
{
|
||||||
|
public static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'smOptions';
|
||||||
|
}
|
||||||
|
}
|
@@ -1,13 +1,32 @@
|
|||||||
<?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 UUID extends Facade
|
class UUID extends Facade
|
||||||
{
|
{
|
||||||
protected static function getFacadeAccessor()
|
protected static function getFacadeAccessor()
|
||||||
{
|
{
|
||||||
return 'uuidConversionFacade';
|
return 'uuidConversionFacade';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
app/Form.php
23
app/Form.php
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -10,13 +29,13 @@ class Form extends Model
|
|||||||
|
|
||||||
'formName',
|
'formName',
|
||||||
'formStructure',
|
'formStructure',
|
||||||
'formStatus'
|
'formStatus',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public function vacancies()
|
public function vacancies()
|
||||||
{
|
{
|
||||||
return $this->hasMany('vacancies', 'vacancyFormID', 'id');
|
return $this->hasMany('App\Vacancy', 'vacancyFormID', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function responses()
|
public function responses()
|
||||||
|
141
app/Helpers/ContextAwareValidator.php
Normal file
141
app/Helpers/ContextAwareValidator.php
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
class ContextAwareValidator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The excludedNames array will make the validator ignore any of these names when including names into the rules.
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $excludedNames = [
|
||||||
|
'_token',
|
||||||
|
'_method',
|
||||||
|
'formName',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility wrapper for json_encode.
|
||||||
|
*
|
||||||
|
* @param array $value The array to be converted.
|
||||||
|
* @return string The JSON representation of $value
|
||||||
|
*/
|
||||||
|
private function encode(array $value): string
|
||||||
|
{
|
||||||
|
return json_encode($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The getValidator() method will take an array of fields from the request body, iterates through them,
|
||||||
|
* and dynamically adds validation rules for them. Depending on parameters, it may or may not generate
|
||||||
|
* a form structure for rendering purposes.
|
||||||
|
*
|
||||||
|
* This method is mostly meant by internal use by means of static proxies (Facades), in order to reduce code repetition;
|
||||||
|
* Using it outside it's directed scope may cause unexpected results; For instance, the method expects inputs to be in array format, e.g. myFieldNameID1[],
|
||||||
|
* myFieldNameID2[], and so on and so forth.
|
||||||
|
*
|
||||||
|
* This isn't checked by the code yet, but if you're implementing it this way in the HTML markup, make sure it's consistent (e.g. use a loop).
|
||||||
|
*
|
||||||
|
* P.S This method automatically ignores the CSRF token for validation.
|
||||||
|
*
|
||||||
|
* @param array $fields The request form fields
|
||||||
|
* @param bool $generateStructure Whether to incldue a JSON-ready form structure for rendering
|
||||||
|
* @param bool $includeFormName Whether to include formName in the list of validation rules
|
||||||
|
* @return Validator|Collection A validator instance you can use to check for validity, or a Collection with a validator and structure (validator, structure)
|
||||||
|
*/
|
||||||
|
public function getValidator(array $fields, bool $generateStructure = false, bool $includeFormName = false)
|
||||||
|
{
|
||||||
|
$formStructure = [];
|
||||||
|
$validator = [];
|
||||||
|
|
||||||
|
if ($includeFormName) {
|
||||||
|
$validator['formName'] = 'required|string|max:100';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($fields as $fieldName => $field) {
|
||||||
|
if (! in_array($fieldName, $this->excludedNames)) {
|
||||||
|
$validator[$fieldName.'.0'] = 'required|string';
|
||||||
|
$validator[$fieldName.'.1'] = 'required|string';
|
||||||
|
|
||||||
|
if ($generateStructure) {
|
||||||
|
$formStructure['fields'][$fieldName]['title'] = $field[0];
|
||||||
|
$formStructure['fields'][$fieldName]['type'] = $field[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$validatorInstance = Validator::make($fields, $validator);
|
||||||
|
|
||||||
|
return ($generateStructure) ?
|
||||||
|
collect([
|
||||||
|
'validator' => $validatorInstance,
|
||||||
|
'structure' => $this->encode($formStructure),
|
||||||
|
])
|
||||||
|
: $validatorInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The getResponseValidator method is similar to the getValidator method; It basically takes
|
||||||
|
* an array of fields from a previous form (that probably went through the other method) and adds validation
|
||||||
|
* to the field names.
|
||||||
|
*
|
||||||
|
* Also generates the storable response structure if you tell it to.
|
||||||
|
*
|
||||||
|
* @param array $fields The received fields
|
||||||
|
* @param array $formStructure The form structure - You must supply this if you want the response structure
|
||||||
|
* @param bool $generateResponseStructure Whether to generate the response structure
|
||||||
|
* @return Validator|Collection A collection or a validator, depending on the args. Will return validatior if only fields are supplied.
|
||||||
|
*/
|
||||||
|
public function getResponseValidator(array $fields, array $formStructure = [], bool $generateResponseStructure = true)
|
||||||
|
{
|
||||||
|
$responseStructure = [];
|
||||||
|
$validator = [];
|
||||||
|
|
||||||
|
if (empty($formStructure) && $generateResponseStructure) {
|
||||||
|
throw new \InvalidArgumentException('Illegal combination of arguments supplied! Please check the method\'s documentation.');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($fields as $fieldName => $value) {
|
||||||
|
if (! in_array($fieldName, $this->excludedNames)) {
|
||||||
|
$validator[$fieldName] = 'required|string';
|
||||||
|
|
||||||
|
if ($generateResponseStructure) {
|
||||||
|
$responseStructure['responses'][$fieldName]['type'] = $formStructure['fields'][$fieldName]['type'] ?? 'Unavailable';
|
||||||
|
$responseStructure['responses'][$fieldName]['title'] = $formStructure['fields'][$fieldName]['title'];
|
||||||
|
$responseStructure['responses'][$fieldName]['response'] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$validatorInstance = Validator::make($fields, $validator);
|
||||||
|
|
||||||
|
return ($generateResponseStructure) ?
|
||||||
|
collect([
|
||||||
|
'validator' => $validatorInstance,
|
||||||
|
'responseStructure' => $this->encode($responseStructure),
|
||||||
|
])
|
||||||
|
: $validatorInstance;
|
||||||
|
}
|
||||||
|
}
|
105
app/Helpers/Options.php
Normal file
105
app/Helpers/Options.php
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use App\Options as Option;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class Options
|
||||||
|
{
|
||||||
|
public function getOption(string $option): string
|
||||||
|
{
|
||||||
|
$value = Cache::get($option);
|
||||||
|
|
||||||
|
if (is_null($value)) {
|
||||||
|
Log::debug('Option '.$option.'not found in cache, refreshing from database');
|
||||||
|
$value = Option::where('option_name', $option)->first();
|
||||||
|
if (is_null($value)) {
|
||||||
|
throw new \Exception('This option does not exist.');
|
||||||
|
}
|
||||||
|
Cache::put($option, $value);
|
||||||
|
Cache::put($option.'_desc', 'Undefined description');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value->option_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOption(string $option, string $value, string $description)
|
||||||
|
{
|
||||||
|
Option::create([
|
||||||
|
'option_name' => $option,
|
||||||
|
'option_value' => $value,
|
||||||
|
'friendly_name' => $description,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Cache::put($option, $value, now()->addDay());
|
||||||
|
Cache::put($option.'_desc', $description, now()->addDay());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pullOption($option): array
|
||||||
|
{
|
||||||
|
$oldOption = Option::where('option_name', $option)->first();
|
||||||
|
Option::find($oldOption->id)->delete();
|
||||||
|
|
||||||
|
// putMany is overkill here
|
||||||
|
return [
|
||||||
|
Cache::pull($option),
|
||||||
|
Cache::pull($option.'_desc'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function changeOption($option, $newValue)
|
||||||
|
{
|
||||||
|
$dbOption = Option::where('option_name', $option);
|
||||||
|
|
||||||
|
if ($dbOption->first()) {
|
||||||
|
$dbOptionInstance = Option::find($dbOption->first()->id);
|
||||||
|
Cache::forget($option);
|
||||||
|
|
||||||
|
Log::debug('Changing db configuration option', [
|
||||||
|
'old_value' => $dbOptionInstance->option_value,
|
||||||
|
'new_value' => $newValue,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$dbOptionInstance->option_value = $newValue;
|
||||||
|
$dbOptionInstance->save();
|
||||||
|
|
||||||
|
Log::debug('New db configuration option saved',
|
||||||
|
[
|
||||||
|
'option' => $dbOptionInstance->option_value,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Cache::put('option_name', $newValue, now()->addDay());
|
||||||
|
} else {
|
||||||
|
throw new \Exception('This option does not exist.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function optionExists(string $option): bool
|
||||||
|
{
|
||||||
|
$dbOption = Option::where('option_name', $option)->first();
|
||||||
|
$locallyCachedOption = Cache::get($option);
|
||||||
|
|
||||||
|
return ! is_null($dbOption) || ! is_null($locallyCachedOption);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,21 +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\Response;
|
|
||||||
use App\Vacancy;
|
|
||||||
use App\User;
|
|
||||||
|
|
||||||
use App\Events\ApplicationDeniedEvent;
|
use App\Events\ApplicationDeniedEvent;
|
||||||
use App\Notifications\NewApplicant;
|
|
||||||
use App\Notifications\ApplicationMoved;
|
use App\Notifications\ApplicationMoved;
|
||||||
|
use App\Notifications\NewApplicant;
|
||||||
|
use App\Response;
|
||||||
|
use App\User;
|
||||||
|
use App\Vacancy;
|
||||||
|
use ContextAwareValidator;
|
||||||
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;
|
||||||
|
|
||||||
class ApplicationController extends Controller
|
class ApplicationController extends Controller
|
||||||
@@ -24,10 +39,8 @@ class ApplicationController extends Controller
|
|||||||
{
|
{
|
||||||
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,26 +48,17 @@ 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, $applicationID)
|
|
||||||
{
|
{
|
||||||
$application = Application::find($applicationID);
|
|
||||||
|
|
||||||
$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(
|
||||||
[
|
[
|
||||||
@@ -63,20 +67,23 @@ 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()
|
||||||
|
{
|
||||||
|
$this->authorize('viewAny', Application::class);
|
||||||
|
|
||||||
|
return view('dashboard.appmanagement.all')
|
||||||
|
->with('applications', Application::paginate(6));
|
||||||
|
}
|
||||||
|
|
||||||
public function showAllPendingApps()
|
public function showAllPendingApps()
|
||||||
{
|
{
|
||||||
@@ -86,10 +93,6 @@ 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);
|
||||||
@@ -99,16 +102,12 @@ class ApplicationController extends Controller
|
|||||||
$pendingInterviews = collect([]);
|
$pendingInterviews = collect([]);
|
||||||
$upcomingInterviews = collect([]);
|
$upcomingInterviews = collect([]);
|
||||||
|
|
||||||
|
foreach ($applications as $application) {
|
||||||
foreach ($applications as $application)
|
if (! is_null($application->appointment) && $application->appointment->appointmentStatus == 'CONCLUDED') {
|
||||||
{
|
$count = +1;
|
||||||
if (!is_null($application->appointment) && $application->appointment->appointmentStatus == 'CONCLUDED')
|
|
||||||
{
|
|
||||||
$count =+ 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($application->applicationStatus)
|
switch ($application->applicationStatus) {
|
||||||
{
|
|
||||||
case 'STAGE_INTERVIEW':
|
case 'STAGE_INTERVIEW':
|
||||||
$upcomingInterviews->push($application);
|
$upcomingInterviews->push($application);
|
||||||
|
|
||||||
@@ -119,29 +118,24 @@ 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
|
||||||
@@ -149,74 +143,44 @@ 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!');
|
||||||
|
|
||||||
$formStructure = json_decode($vacancy->first()->forms->formStructure, true);
|
$formStructure = json_decode($vacancy->first()->forms->formStructure, true);
|
||||||
$responseStructure = [];
|
$responseValidation = ContextAwareValidator::getResponseValidator($request->all(), $formStructure);
|
||||||
|
|
||||||
$excludedNames = [
|
|
||||||
'_token',
|
|
||||||
];
|
|
||||||
|
|
||||||
$validator = [];
|
|
||||||
|
|
||||||
foreach($request->all() as $fieldName => $value)
|
|
||||||
{
|
|
||||||
if(!in_array($fieldName, $excludedNames))
|
|
||||||
{
|
|
||||||
$validator[$fieldName] = 'required|string';
|
|
||||||
|
|
||||||
$responseStructure['responses'][$fieldName]['type'] = $formStructure['fields'][$fieldName]['type'] ?? 'Unavailable';
|
|
||||||
$responseStructure['responses'][$fieldName]['title'] = $formStructure['fields'][$fieldName]['title'];
|
|
||||||
$responseStructure['responses'][$fieldName]['response'] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info('Built response & validator structure!');
|
Log::info('Built response & validator structure!');
|
||||||
|
|
||||||
$validation = Validator::make($request->all(), $validator);
|
if (! $responseValidation->get('validator')->fails()) {
|
||||||
|
|
||||||
if (!$validation->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' => json_encode($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);
|
||||||
|
|
||||||
$application = Application::create([
|
$application = Application::create([
|
||||||
'applicantUserID' => Auth::user()->id,
|
'applicantUserID' => Auth::user()->id,
|
||||||
@@ -224,60 +188,57 @@ class ApplicationController extends Controller
|
|||||||
'applicationStatus' => 'STAGE_SUBMITTED',
|
'applicationStatus' => 'STAGE_SUBMITTED',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
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'));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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.');
|
|
||||||
|
|
||||||
|
return redirect()->to(route('showUserApps'));
|
||||||
|
} else {
|
||||||
|
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.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateApplicationStatus(Request $request, $applicationID, $newStatus)
|
public function updateApplicationStatus(Request $request, Application $application, $newStatus)
|
||||||
{
|
{
|
||||||
$application = Application::find($applicationID);
|
|
||||||
$this->authorize('update', Application::class);
|
$this->authorize('update', Application::class);
|
||||||
|
|
||||||
if (!is_null($application))
|
switch ($newStatus) {
|
||||||
{
|
case 'deny':
|
||||||
switch ($newStatus)
|
|
||||||
{
|
|
||||||
case 'deny':
|
|
||||||
|
|
||||||
event(new ApplicationDeniedEvent($application));
|
event(new ApplicationDeniedEvent($application));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'interview':
|
case 'interview':
|
||||||
Log::info('User ' . Auth::user()->name . ' has moved application ID ' . $application->id . 'to interview stage');
|
Log::info('User '.Auth::user()->name.' has moved application ID '.$application->id.'to interview stage');
|
||||||
$request->session()->flash('success', 'Application moved to interview stage! (:');
|
$request->session()->flash('success', 'Application moved to interview stage! (:');
|
||||||
$application->setStatus('STAGE_INTERVIEW');
|
$application->setStatus('STAGE_INTERVIEW');
|
||||||
|
|
||||||
$application->user->notify(new ApplicationMoved());
|
$application->user->notify(new ApplicationMoved());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$request->session()->flash('error', 'There are no suitable statuses to update to. Do not mess with the URL.');
|
$request->session()->flash('error', 'There are no suitable statuses to update to. Do not mess with the URL.');
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$request->session()->flash('The application you\'re trying to update does not exist.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(Request $request, Application $application)
|
||||||
|
{
|
||||||
|
$this->authorize('delete', $application);
|
||||||
|
$application->delete(); // observers will run, cleaning it up
|
||||||
|
|
||||||
|
$request->session()->flash('success', 'Application deleted. Comments, appointments and responses have also been deleted.');
|
||||||
|
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,14 +1,33 @@
|
|||||||
<?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\SaveNotesRequest;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Appointment;
|
use App\Appointment;
|
||||||
|
use App\Http\Requests\SaveNotesRequest;
|
||||||
use App\Notifications\ApplicationMoved;
|
use App\Notifications\ApplicationMoved;
|
||||||
use App\Notifications\AppointmentScheduled;
|
use App\Notifications\AppointmentScheduled;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@@ -20,99 +39,69 @@ class AppointmentController extends Controller
|
|||||||
'DISCORD',
|
'DISCORD',
|
||||||
'SKYPE',
|
'SKYPE',
|
||||||
'MEET',
|
'MEET',
|
||||||
'TEAMSPEAK'
|
'TEAMSPEAK',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public function saveAppointment(Request $request, $applicationID)
|
public function saveAppointment(Request $request, Application $application)
|
||||||
{
|
{
|
||||||
// Unrelated TODO: change if's in application page to a switch statement, & have the row encompass it
|
|
||||||
|
|
||||||
$this->authorize('create', Appointment::class);
|
$this->authorize('create', Appointment::class);
|
||||||
|
$appointmentDate = Carbon::parse($request->appointmentDateTime);
|
||||||
|
|
||||||
$app = Application::find($applicationID);
|
$appointment = Appointment::create([
|
||||||
|
'appointmentDescription' => $request->appointmentDescription,
|
||||||
|
'appointmentDate' => $appointmentDate->toDateTimeString(),
|
||||||
|
'applicationID' => $application->id,
|
||||||
|
'appointmentLocation' => (in_array($request->appointmentLocation, $this->allowedPlatforms)) ? $request->appointmentLocation : 'DISCORD',
|
||||||
|
]);
|
||||||
|
$application->setStatus('STAGE_INTERVIEW_SCHEDULED');
|
||||||
|
|
||||||
if (!is_null($app))
|
Log::info('User '.Auth::user()->name.' has scheduled an appointment with '.$application->user->name.' for application ID'.$application->id, [
|
||||||
{
|
'datetime' => $appointmentDate->toDateTimeString(),
|
||||||
// make sure this is a valid date by parsing it first
|
'scheduled' => now(),
|
||||||
$appointmentDate = Carbon::parse($request->appointmentDateTime);
|
]);
|
||||||
|
|
||||||
|
$application->user->notify(new AppointmentScheduled($appointment));
|
||||||
$appointment = Appointment::create([
|
$request->session()->flash('success', 'Appointment successfully scheduled @ '.$appointmentDate->toDateTimeString());
|
||||||
'appointmentDescription' => $request->appointmentDescription,
|
|
||||||
'appointmentDate' => $appointmentDate->toDateTimeString(),
|
|
||||||
'applicationID' => $applicationID,
|
|
||||||
'appointmentLocation' => (in_array($request->appointmentLocation, $this->allowedPlatforms)) ? $request->appointmentLocation : 'DISCORD',
|
|
||||||
]);
|
|
||||||
$app->setStatus('STAGE_INTERVIEW_SCHEDULED');
|
|
||||||
|
|
||||||
|
|
||||||
Log::info('User ' . Auth::user()->name . ' has scheduled an appointment with ' . $app->user->name . ' for application ID' . $app->id, [
|
|
||||||
'datetime' => $appointmentDate->toDateTimeString(),
|
|
||||||
'scheduled' => now()
|
|
||||||
]);
|
|
||||||
|
|
||||||
$app->user->notify(new AppointmentScheduled($appointment));
|
|
||||||
$request->session()->flash('success', 'Appointment successfully scheduled @ ' . $appointmentDate->toDateTimeString());
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$request->session()->flash('error', 'Cant\'t schedule an appointment for an application that doesn\'t exist.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateAppointment(Request $request, $applicationID, $status)
|
public function updateAppointment(Request $request, Application $application, $status)
|
||||||
{
|
{
|
||||||
|
$this->authorize('update', $application->appointment);
|
||||||
|
|
||||||
$this->authorize('update', Appointment::class);
|
|
||||||
|
|
||||||
$application = Application::find($applicationID);
|
|
||||||
$validStatuses = [
|
$validStatuses = [
|
||||||
'SCHEDULED',
|
'SCHEDULED',
|
||||||
'CONCLUDED'
|
'CONCLUDED',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// NOTE: This is a little confusing, refactor
|
||||||
|
$application->appointment->appointmentStatus = (in_array($status, $validStatuses)) ? strtoupper($status) : 'SCHEDULED';
|
||||||
|
$application->appointment->save();
|
||||||
|
|
||||||
if (!is_null($application))
|
$application->setStatus('STAGE_PEERAPPROVAL');
|
||||||
{
|
$application->user->notify(new ApplicationMoved());
|
||||||
// NOTE: This is a little confusing, refactor
|
|
||||||
$application->appointment->appointmentStatus = (in_array($status, $validStatuses)) ? strtoupper($status) : 'SCHEDULED';
|
|
||||||
$application->appointment->save();
|
|
||||||
|
|
||||||
$application->setStatus('STAGE_PEERAPPROVAL');
|
$request->session()->flash('success', 'Interview finished! Staff members can now vote on it.');
|
||||||
$application->user->notify(new ApplicationMoved());
|
|
||||||
|
|
||||||
$request->session()->flash('success', 'Interview finished! Staff members can now vote on it.');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$request->session()->flash('error', 'The application you\'re trying to update doesn\'t exist or have an appointment.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
// also updates
|
// also updates
|
||||||
public function saveNotes(SaveNotesRequest $request, $applicationID)
|
public function saveNotes(SaveNotesRequest $request, Application $application)
|
||||||
{
|
{
|
||||||
$application = Application::find($applicationID);
|
if (! is_null($application)) {
|
||||||
|
$application->load('appointment');
|
||||||
|
|
||||||
if (!is_null($application))
|
|
||||||
{
|
|
||||||
$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', 'Sanity check failed: There\'s no appointment to save notes to!');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,27 @@
|
|||||||
<?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,5 +1,24 @@
|
|||||||
<?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,10 +1,28 @@
|
|||||||
<?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\User;
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Providers\RouteServiceProvider;
|
use App\User;
|
||||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -44,26 +62,19 @@ class LoginController extends Controller
|
|||||||
|
|
||||||
// We can't customise the error message, since that would imply overriding the login method, which is large.
|
// We can't customise the error message, since that would imply overriding the login method, which is large.
|
||||||
// Also, the user should never know that they're banned.
|
// Also, the user should never know that they're banned.
|
||||||
public function attemptLogin(Request $request)
|
public function attemptLogin(Request $request)
|
||||||
{
|
{
|
||||||
$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,15 +1,32 @@
|
|||||||
<?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
|
||||||
{
|
{
|
||||||
@@ -47,10 +64,8 @@ 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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,9 +85,9 @@ class RegisterController extends Controller
|
|||||||
'uuid' => ['required', 'string', 'unique:users', 'min:32', 'max:32'],
|
'uuid' => ['required', 'string', 'unique:users', 'min:32', 'max:32'],
|
||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
'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.',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,19 +99,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,9 +1,27 @@
|
|||||||
<?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
|
||||||
|
32
app/Http/Controllers/Auth/TwofaController.php
Normal file
32
app/Http/Controllers/Auth/TwofaController.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Traits\AuthenticatesTwoFactor;
|
||||||
|
|
||||||
|
class TwofaController extends Controller
|
||||||
|
{
|
||||||
|
use AuthenticatesTwoFactor;
|
||||||
|
|
||||||
|
protected $redirectTo = '/dashboard';
|
||||||
|
}
|
@@ -1,9 +1,27 @@
|
|||||||
<?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,91 +1,94 @@
|
|||||||
<?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;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use App\Ban;
|
use App\Ban;
|
||||||
use App\User;
|
|
||||||
use App\Events\UserBannedEvent;
|
use App\Events\UserBannedEvent;
|
||||||
use App\Http\Requests\BanUserRequest;
|
use App\Http\Requests\BanUserRequest;
|
||||||
|
use App\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
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]);
|
||||||
|
|
||||||
if ($user->is(Auth::user()))
|
if (is_null($user->bans)) {
|
||||||
{
|
|
||||||
$request->session()->flash('error', 'You can\'t ban yourself!');
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
if (!empty($duration))
|
if (! empty($duration)) {
|
||||||
{
|
switch ($duration) {
|
||||||
$expiryDate = now();
|
|
||||||
|
|
||||||
switch($duration)
|
|
||||||
{
|
|
||||||
case 'days':
|
case 'days':
|
||||||
$expiryDate->addDays($duration);
|
$expiryDate->addDays($durationOperand);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'weeks':
|
case 'weeks':
|
||||||
$expiryDate->addWeeks($duration);
|
$expiryDate->addWeeks($durationOperand);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'months':
|
case 'months':
|
||||||
$expiryDate->addMonths($duration);
|
$expiryDate->addMonths($durationOperand);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'years':
|
case 'years':
|
||||||
$expiryDate->addYears($duration);
|
$expiryDate->addYears($durationOperand);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Essentially permanent
|
||||||
|
$expiryDate->addYears(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ban = Ban::create([
|
$ban = Ban::create([
|
||||||
'userID' => $user->id,
|
'userID' => $user->id,
|
||||||
'reason' => $request->reason,
|
'reason' => $reason,
|
||||||
'bannedUntil' => $expiryDate->toDateTimeString() ?? null,
|
'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,19 +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\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()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -22,33 +37,20 @@ class CommentController extends Controller
|
|||||||
public function insert(NewCommentRequest $request, Application $application)
|
public function insert(NewCommentRequest $request, Application $application)
|
||||||
{
|
{
|
||||||
$this->authorize('create', Comment::class);
|
$this->authorize('create', Comment::class);
|
||||||
|
|
||||||
$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) {
|
||||||
{
|
|
||||||
|
|
||||||
foreach (User::all() as $user)
|
|
||||||
{
|
|
||||||
if ($user->isStaffMember())
|
|
||||||
{
|
|
||||||
$user->notify(new NewComment($comment, $application));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$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)
|
||||||
@@ -59,7 +61,5 @@ class CommentController extends Controller
|
|||||||
$request->session()->flash('success', 'Comment deleted!');
|
$request->session()->flash('success', 'Comment deleted!');
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,39 @@
|
|||||||
<?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 Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
class ContactController extends Controller
|
class ContactController extends Controller
|
||||||
{
|
{
|
||||||
|
protected $users;
|
||||||
|
|
||||||
|
public function __construct(User $users)
|
||||||
|
{
|
||||||
|
$this->users = $users;
|
||||||
|
}
|
||||||
|
|
||||||
public function create(Request $request)
|
public function create(Request $request)
|
||||||
{
|
{
|
||||||
@@ -18,23 +44,33 @@ class ContactController extends Controller
|
|||||||
|
|
||||||
$challenge = $request->input('captcha');
|
$challenge = $request->input('captcha');
|
||||||
|
|
||||||
|
// TODO: now: add middleware for this verification, move to invisible captcha
|
||||||
$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' => $_SERVER['REMOTE_ADDR']
|
'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();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Send mail
|
foreach (User::all() as $user) {
|
||||||
|
if ($user->hasRole('admin')) {
|
||||||
|
$user->notify(new NewContact(collect([
|
||||||
|
'message' => $msg,
|
||||||
|
'ip' => $request->ip(),
|
||||||
|
'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,5 +1,24 @@
|
|||||||
<?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,16 +1,32 @@
|
|||||||
<?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;
|
|
||||||
use App\Vacancy;
|
|
||||||
use App\User;
|
|
||||||
use App\Ban;
|
|
||||||
use App\Application;
|
use App\Application;
|
||||||
|
use App\User;
|
||||||
|
use App\Vacancy;
|
||||||
|
|
||||||
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();
|
||||||
@@ -19,13 +35,11 @@ class DashboardController extends Controller
|
|||||||
|
|
||||||
return view('dashboard.dashboard')
|
return view('dashboard.dashboard')
|
||||||
->with([
|
->with([
|
||||||
'vacancies' => Vacancy::all(),
|
'vacancies' => Vacancy::all(),
|
||||||
'totalUserCount' => User::all()->count(),
|
'totalUserCount' => User::all()->count(),
|
||||||
'totalDenied' => $totalDenied,
|
'totalDenied' => $totalDenied,
|
||||||
'totalPeerReview' => $totalPeerReview,
|
'totalPeerReview' => $totalPeerReview,
|
||||||
'totalNewApplications' => $totalNewApplications
|
'totalNewApplications' => $totalNewApplications,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,31 +1,59 @@
|
|||||||
<?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;
|
||||||
|
|
||||||
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.
|
||||||
|
protected function isolatedAuthorise()
|
||||||
|
{
|
||||||
|
if (! Auth::user()->can('admin.developertools.use')) {
|
||||||
|
abort(403, 'You\'re not authorized to access this page.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
$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());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function forceVoteCount(Request $request)
|
public function forceVoteCount(Request $request)
|
||||||
{
|
{
|
||||||
|
$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,15 +1,32 @@
|
|||||||
<?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;
|
|
||||||
|
|
||||||
class FormController extends Controller
|
class FormController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$forms = Form::all();
|
$forms = Form::all();
|
||||||
@@ -22,77 +39,97 @@ 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();
|
||||||
|
|
||||||
$formFields = $request->all();
|
$contextValidation = ContextAwareValidator::getValidator($fields, true, true);
|
||||||
|
|
||||||
$formStructure = [];
|
if (! $contextValidation->get('validator')->fails()) {
|
||||||
$excludedNames = [
|
$storableFormStructure = $contextValidation->get('structure');
|
||||||
'_token',
|
|
||||||
'formName' // It's added outside the loop. Not excluding causes unwanted duplication.
|
|
||||||
];
|
|
||||||
$validator = [
|
|
||||||
'formName' => 'required|string|max:100'
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($formFields as $fieldName => $field)
|
|
||||||
{
|
|
||||||
if(!in_array($fieldName, $excludedNames))
|
|
||||||
{
|
|
||||||
$validator[$fieldName . ".0"] = 'required|string';
|
|
||||||
$validator[$fieldName . ".1"] = 'required|string';
|
|
||||||
|
|
||||||
$formStructure['fields'][$fieldName]['title'] = $field[0];
|
|
||||||
$formStructure['fields'][$fieldName]['type'] = $field[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$validation = Validator::make($formFields, $validator);
|
|
||||||
|
|
||||||
if (!$validation->fails())
|
|
||||||
{
|
|
||||||
$storableFormStructure = json_encode($formStructure);
|
|
||||||
|
|
||||||
Form::create(
|
Form::create(
|
||||||
[
|
[
|
||||||
'formName' => $formFields['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', $validation->errors()->getMessages());
|
$request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages());
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(Request $request, $id)
|
public function destroy(Request $request, Form $form)
|
||||||
{
|
{
|
||||||
|
|
||||||
$form = Form::find($id);
|
|
||||||
$this->authorize('delete', $form);
|
$this->authorize('delete', $form);
|
||||||
|
$deletable = true;
|
||||||
|
|
||||||
// TODO: Check if form is linked to vacancies before allowing deletion
|
if (! is_null($form) && ! is_null($form->vacancies) && $form->vacancies->count() !== 0 || ! is_null($form->responses)) {
|
||||||
if (!is_null($form))
|
$deletable = false;
|
||||||
{
|
}
|
||||||
|
|
||||||
|
if ($deletable) {
|
||||||
$form->delete();
|
$form->delete();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Form deleted successfully.');
|
$request->session()->flash('success', 'Form deleted successfully.');
|
||||||
return redirect()->back();
|
} 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', 'The form you\'re trying to delete does not exist.');
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function preview(Request $request, Form $form)
|
||||||
|
{
|
||||||
|
$this->authorize('viewAny', Form::class);
|
||||||
|
|
||||||
|
return view('dashboard.administration.formpreview')
|
||||||
|
->with('form', json_decode($form->formStructure, true))
|
||||||
|
->with('title', $form->formName)
|
||||||
|
->with('formID', $form->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(Request $request, Form $form)
|
||||||
|
{
|
||||||
|
$this->authorize('update', $form);
|
||||||
|
|
||||||
|
return view('dashboard.administration.editform')
|
||||||
|
->with('formStructure', json_decode($form->formStructure, true))
|
||||||
|
->with('title', $form->formName)
|
||||||
|
->with('formID', $form->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, Form $form)
|
||||||
|
{
|
||||||
|
$this->authorize('update', $form);
|
||||||
|
|
||||||
|
$contextValidation = ContextAwareValidator::getValidator($request->all(), true);
|
||||||
|
$this->authorize('update', $form);
|
||||||
|
|
||||||
|
if (! $contextValidation->get('validator')->fails()) {
|
||||||
|
// 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.
|
||||||
|
// 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
|
||||||
|
$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.');
|
||||||
|
} else {
|
||||||
|
$request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages());
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->to(route('previewForm', ['form' => $form->id]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,27 @@
|
|||||||
<?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
|
||||||
{
|
{
|
||||||
@@ -15,14 +32,9 @@ class HomeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
// TODO: Relationships for Applications, Users and Responses
|
$positions = Vacancy::where('vacancyStatus', 'OPEN')
|
||||||
// Also prevent apps if user already has one in the space of 30d
|
->where('vacancyCount', '<>', 0)
|
||||||
// Display apps in the relevant menus
|
->get();
|
||||||
|
|
||||||
$positions = DB::table('vacancies')
|
|
||||||
->where('vacancyStatus', 'OPEN')
|
|
||||||
->where('vacancyCount', '!=', 0)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
return view('home')
|
return view('home')
|
||||||
->with('positions', $positions);
|
->with('positions', $positions);
|
||||||
|
85
app/Http/Controllers/OptionsController.php
Normal file
85
app/Http/Controllers/OptionsController.php
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use App\Facades\Options;
|
||||||
|
use App\Options as Option;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class OptionsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Http\Response|\Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
// TODO: Obtain this from the facade
|
||||||
|
$options = Option::all();
|
||||||
|
|
||||||
|
return view('dashboard.administration.settings')
|
||||||
|
->with('options', $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveSettings(Request $request)
|
||||||
|
{
|
||||||
|
if (Auth::user()->can('admin.settings.edit')) {
|
||||||
|
Log::debug('Updating application options', [
|
||||||
|
'ip' => $request->ip(),
|
||||||
|
'ua' => $request->userAgent(),
|
||||||
|
'username' => Auth::user()->username,
|
||||||
|
]);
|
||||||
|
foreach ($request->all() as $optionName => $option) {
|
||||||
|
try {
|
||||||
|
Log::debug('Going through option '.$optionName);
|
||||||
|
if (Options::optionExists($optionName)) {
|
||||||
|
Log::debug('Option exists, updating to new values', [
|
||||||
|
'opt' => $optionName,
|
||||||
|
'new_value' => $option,
|
||||||
|
]);
|
||||||
|
Options::changeOption($optionName, $option);
|
||||||
|
}
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
Log::error('Unable to update options!', [
|
||||||
|
'msg' => $ex->getMessage(),
|
||||||
|
'trace' => $ex->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
report($ex);
|
||||||
|
|
||||||
|
$errorCond = true;
|
||||||
|
$request->session()->flash('error', 'An error occurred while trying to save settings: '.$ex->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! isset($errorCond)) {
|
||||||
|
$request->session()->flash('success', 'Settings saved successfully!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$request->session()->flash('error', 'You do not have permission to update this resource.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
}
|
@@ -1,12 +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\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Requests\ProfileSave;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\Profile;
|
|
||||||
use App\User;
|
|
||||||
use App\Facades\IP;
|
use App\Facades\IP;
|
||||||
|
use App\Http\Requests\ProfileSave;
|
||||||
|
use App\User;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@@ -14,18 +31,15 @@ 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')
|
||||||
@@ -36,13 +50,11 @@ 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);
|
||||||
|
|
||||||
@@ -51,21 +63,15 @@ class ProfileController extends Controller
|
|||||||
|
|
||||||
$roleList = [];
|
$roleList = [];
|
||||||
|
|
||||||
|
foreach ($systemRoles as $role) {
|
||||||
foreach($systemRoles as $role)
|
if (in_array($role, $userRoles)) {
|
||||||
{
|
$roleList[$role] = true;
|
||||||
if (in_array($role, $userRoles))
|
} else {
|
||||||
{
|
$roleList[$role] = false;
|
||||||
$roleList[$role] = true;
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$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,
|
||||||
@@ -73,28 +79,22 @@ 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)
|
||||||
{
|
{
|
||||||
// TODO: Switch to route model binding
|
|
||||||
$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,24 +118,8 @@ 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.');
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$gm = 'Guru Meditation #' . rand(0, 1000);
|
|
||||||
Log::alert('[GURU MEDITATION]: Could not find profile for authenticated user ' . Auth::user()->name . 'whilst trying to update it! Please verify that profiles are being created automatically during signup.',
|
|
||||||
[
|
|
||||||
'uuid' => Auth::user()->uuid,
|
|
||||||
'timestamp' => now(),
|
|
||||||
'route' => $request->route()->getName(),
|
|
||||||
'gmcode' => $gm // If this error is reported, the GM code, denoting a severe error, will help us find this entry in the logs
|
|
||||||
|
|
||||||
]);
|
|
||||||
$request->session()->flash('error', 'A technical error has occurred whilst trying to save your profile. Incident details have been recorded. Please report this incident to administrators with the following case number: ' . $gm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
class ResponseController extends Controller
|
class ResponseController extends Controller
|
||||||
{
|
{
|
||||||
|
@@ -1,8 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
class StaffProfileController extends Controller
|
class StaffProfileController extends Controller
|
||||||
{
|
{
|
||||||
|
@@ -1,30 +1,47 @@
|
|||||||
<?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\FlushSessionsRequest;
|
|
||||||
use App\Http\Requests\DeleteUserRequest;
|
use App\Http\Requests\DeleteUserRequest;
|
||||||
|
use App\Http\Requests\FlushSessionsRequest;
|
||||||
|
use App\Http\Requests\Remove2FASecretRequest;
|
||||||
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\Notifications\EmailChanged;
|
||||||
use App\User;
|
use App\User;
|
||||||
use App\Ban;
|
use Google2FA;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public function showStaffMembers()
|
public function showStaffMembers()
|
||||||
{
|
{
|
||||||
$this->authorize('viewStaff', User::class);
|
$this->authorize('viewStaff', User::class);
|
||||||
@@ -32,24 +49,20 @@ 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
|
||||||
}
|
}
|
||||||
@@ -58,7 +71,7 @@ class UserController extends Controller
|
|||||||
|
|
||||||
return view('dashboard.administration.staff-members')
|
return view('dashboard.administration.staff-members')
|
||||||
->with([
|
->with([
|
||||||
'users' => $staffMembers
|
'users' => $staffMembers,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,11 +82,9 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,11 +92,10 @@ 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);
|
||||||
@@ -96,28 +106,44 @@ 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'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showAccount()
|
public function showAccount(Request $request)
|
||||||
{
|
{
|
||||||
return view('dashboard.user.profile.useraccount')
|
$QRCode = null;
|
||||||
->with('ip', request()->ip());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (! $request->user()->has2FA()) {
|
||||||
|
if ($request->session()->has('twofaAttemptFailed')) {
|
||||||
|
$twoFactorSecret = $request->session()->get('current2FA');
|
||||||
|
} else {
|
||||||
|
$twoFactorSecret = Google2FA::generateSecretKey(32, '');
|
||||||
|
$request->session()->put('current2FA', $twoFactorSecret);
|
||||||
|
}
|
||||||
|
|
||||||
|
$QRCode = Google2FA::getQRCodeInline(
|
||||||
|
config('app.name'),
|
||||||
|
$request->user()->email,
|
||||||
|
$twoFactorSecret
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('dashboard.user.profile.useraccount')
|
||||||
|
->with('ip', request()->ip())
|
||||||
|
->with('twofaQRCode', $QRCode);
|
||||||
|
}
|
||||||
|
|
||||||
public function flushSessions(FlushSessionsRequest $request)
|
public function flushSessions(FlushSessionsRequest $request)
|
||||||
{
|
{
|
||||||
@@ -125,14 +151,15 @@ class UserController extends Controller
|
|||||||
// This will allow for other actions to be performed on certain events (like login failed event)
|
// This will allow for other actions to be performed on certain events (like login failed event)
|
||||||
|
|
||||||
Auth::logoutOtherDevices($request->currentPasswordFlush);
|
Auth::logoutOtherDevices($request->currentPasswordFlush);
|
||||||
Log::notice('User ' . Auth::user()->name . ' has logged out other devices in their account',
|
Log::notice('User '.Auth::user()->name.' has logged out other devices in their account',
|
||||||
[
|
[
|
||||||
'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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,129 +167,165 @@ 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)
|
||||||
{
|
{
|
||||||
if ($request->confirmPrompt == 'DELETE ACCOUNT')
|
$this->authorize('delete', $user);
|
||||||
{
|
|
||||||
|
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);
|
||||||
|
|
||||||
// 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
|
||||||
$user->email = $request->email;
|
$user->email = $request->email;
|
||||||
$user->name = $request->name;
|
$user->name = $request->name;
|
||||||
$user->uuid = $request->uuid;
|
$user->uuid = $request->uuid;
|
||||||
|
|
||||||
$existingRoles = Role::all()
|
$existingRoles = Role::all()
|
||||||
->pluck('name')
|
->pluck('name')
|
||||||
->all();
|
->all();
|
||||||
|
|
||||||
$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)
|
|
||||||
{
|
|
||||||
if (!$user->hasRole($role))
|
|
||||||
{
|
|
||||||
$user->assignRole($role);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
foreach ($request->roles as $role) {
|
||||||
|
if (! $user->hasRole($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)
|
||||||
|
{
|
||||||
|
$currentSecret = $request->session()->get('current2FA');
|
||||||
|
$isValid = Google2FA::verifyKey($currentSecret, $request->otp);
|
||||||
|
|
||||||
|
if ($isValid) {
|
||||||
|
$request->user()->twofa_secret = $currentSecret;
|
||||||
|
$request->user()->save();
|
||||||
|
|
||||||
|
Log::warning('SECURITY: User activated two-factor authentication', [
|
||||||
|
'initiator' => $request->user()->email,
|
||||||
|
'ip' => $request->ip(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Google2FA::login();
|
||||||
|
|
||||||
|
Log::warning('SECURITY: Started two factor session automatically', [
|
||||||
|
'initiator' => $request->user()->email,
|
||||||
|
'ip' => $request->ip(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$request->session()->forget('current2FA');
|
||||||
|
|
||||||
|
if ($request->session()->has('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.');
|
||||||
|
} else {
|
||||||
|
$request->session()->flash('error', 'Incorrect code. Please reopen the 2FA settings panel and try again.');
|
||||||
|
$request->session()->put('twofaAttemptFailed', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove2FASecret(Remove2FASecretRequest $request)
|
||||||
|
{
|
||||||
|
Log::warning('SECURITY: Disabling two factor authentication (user initiated)', [
|
||||||
|
'initiator' => $request->user()->email,
|
||||||
|
'ip' => $request->ip(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$request->user()->twofa_secret = null;
|
||||||
|
$request->user()->save();
|
||||||
|
|
||||||
|
$request->session()->flash('success', 'Two-factor authentication disabled.');
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
if (!$user->isStaffMember() || $user->is(Auth::user()))
|
// 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();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($user->roles as $role)
|
foreach ($user->roles as $role) {
|
||||||
{
|
if ($role->name == 'user') {
|
||||||
if ($role->name == 'user')
|
continue;
|
||||||
{
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user->removeRole($role->name);
|
$user->removeRole($role->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info('User ' . $user->name . ' has just been demoted.');
|
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
|
//TODO: Dispatch event
|
||||||
|
@@ -1,26 +1,45 @@
|
|||||||
<?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\Http\Requests\VacancyRequest;
|
|
||||||
use App\Vacancy;
|
|
||||||
use App\User;
|
|
||||||
use App\Form;
|
use App\Form;
|
||||||
|
use App\Http\Requests\VacancyEditRequest;
|
||||||
|
use App\Http\Requests\VacancyRequest;
|
||||||
use App\Notifications\VacancyClosed;
|
use App\Notifications\VacancyClosed;
|
||||||
|
use App\User;
|
||||||
|
use App\Vacancy;
|
||||||
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(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,59 +48,55 @@ 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,
|
||||||
|
* 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;
|
||||||
|
* however, the Model can be configured to return MD instead of HTML on that specific field saving us from looping.
|
||||||
|
*/
|
||||||
Vacancy::create([
|
Vacancy::create([
|
||||||
|
|
||||||
'vacancyName' => $request->vacancyName,
|
'vacancyName' => $request->vacancyName,
|
||||||
'vacancyDescription' => $request->vacancyDescription,
|
'vacancyDescription' => $request->vacancyDescription,
|
||||||
|
'vacancyFullDescription' => $request->vacancyFullDescription,
|
||||||
'vacancySlug' => Str::slug($request->vacancyName),
|
'vacancySlug' => Str::slug($request->vacancyName),
|
||||||
'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, $id)
|
public function updatePositionAvailability(Request $request, $status, Vacancy $vacancy)
|
||||||
{
|
{
|
||||||
|
|
||||||
$vacancy = Vacancy::find($id);
|
|
||||||
$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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -90,15 +105,36 @@ 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)
|
||||||
|
{
|
||||||
|
$this->authorize('update', $vacancy);
|
||||||
|
|
||||||
|
return view('dashboard.administration.editposition')
|
||||||
|
->with('vacancy', $vacancy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(VacancyEditRequest $request, Vacancy $vacancy)
|
||||||
|
{
|
||||||
|
$this->authorize('update', $vacancy);
|
||||||
|
|
||||||
|
$vacancy->vacancyFullDescription = $request->vacancyFullDescription;
|
||||||
|
$vacancy->vacancyDescription = $request->vacancyDescription;
|
||||||
|
$vacancy->vacancyCount = $request->vacancyCount;
|
||||||
|
|
||||||
|
$vacancy->save();
|
||||||
|
|
||||||
|
$request->session()->flash('success', 'Vacancy successfully updated.');
|
||||||
|
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,45 +1,50 @@
|
|||||||
<?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, $applicationID)
|
|
||||||
{
|
{
|
||||||
$application = Application::find($applicationID);
|
|
||||||
$this->authorize('create', Vote::class);
|
$this->authorize('create', Vote::class);
|
||||||
|
|
||||||
if (!is_null($application))
|
$vote = Vote::create([
|
||||||
{
|
'userID' => Auth::user()->id,
|
||||||
$vote = Vote::create([
|
'allowedVoteType' => $voteRequest->voteType,
|
||||||
'userID' => Auth::user()->id,
|
]);
|
||||||
'allowedVoteType' => $voteRequest->voteType,
|
$vote->application()->attach($application->id);
|
||||||
]);
|
|
||||||
|
|
||||||
$vote->application()->attach($applicationID);
|
Log::info('User '.Auth::user()->name.' has voted in applicant '.$application->user->name.'\'s application', [
|
||||||
|
'voteType' => $voteRequest->voteType,
|
||||||
Log::info('User ' . Auth::user()->name . ' has voted in applicant ' . $application->user->name . '\'s application', [
|
]);
|
||||||
'voteType' => $voteRequest->voteType
|
$voteRequest->session()->flash('success', 'Your vote has been registered!');
|
||||||
]);
|
|
||||||
|
|
||||||
$voteRequest->session()->flash('success', 'Your vote has been registered! You will now be notified about the outcome of this application.');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$voteRequest->session()->flash('error', 'Can\t vote a non existant application!');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cron job will run command that processes votes
|
// Cron job will run command that processes votes
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -64,6 +83,12 @@ class Kernel extends HttpKernel
|
|||||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
'eligibility' => \App\Http\Middleware\ApplicationEligibility::class,
|
'eligibility' => \App\Http\Middleware\ApplicationEligibility::class,
|
||||||
'usernameUUID' => \App\Http\Middleware\UsernameUUID::class,
|
'usernameUUID' => \App\Http\Middleware\UsernameUUID::class,
|
||||||
'forcelogout' => \App\Http\Middleware\ForceLogoutMiddleware::class
|
'forcelogout' => \App\Http\Middleware\ForceLogoutMiddleware::class,
|
||||||
|
'2fa' => \PragmaRX\Google2FALaravel\Middleware::class,
|
||||||
|
'localize' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class,
|
||||||
|
'localizationRedirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class,
|
||||||
|
'localeSessionRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class,
|
||||||
|
'localeCookieRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleCookieRedirect::class,
|
||||||
|
'localeViewPath' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationViewPath::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,31 @@
|
|||||||
<?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
|
||||||
@@ -23,37 +42,29 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$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,5 +1,24 @@
|
|||||||
<?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,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -20,17 +39,11 @@ 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,5 +1,24 @@
|
|||||||
<?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,5 +1,24 @@
|
|||||||
<?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,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -16,11 +35,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,5 +1,24 @@
|
|||||||
<?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,5 +1,24 @@
|
|||||||
<?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,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -12,12 +31,12 @@ 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.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
protected $headers = Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||||
}
|
}
|
||||||
|
@@ -1,14 +1,33 @@
|
|||||||
<?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 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
|
||||||
@@ -17,18 +36,21 @@ 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 {
|
||||||
// TODO: Switch to custom Facade
|
$username = $input['uuid'];
|
||||||
$username = $input['uuid'];
|
$input['uuid'] = UUID::toUUID($username);
|
||||||
|
} catch (\InvalidArgumentException $iae) {
|
||||||
|
report($iae);
|
||||||
|
|
||||||
$conversionRequest = Http::get(config('general.urls.mojang.api') . '/users/profiles/minecraft/' . $username)->body();
|
$request->session()->flash('error', $iae->getMessage());
|
||||||
$decodedConversionRequest = json_decode($conversionRequest, true);
|
|
||||||
|
|
||||||
$input['uuid'] = $decodedConversionRequest['id'];
|
return redirect(route('register'));
|
||||||
|
}
|
||||||
|
|
||||||
$request->replace($input);
|
$request->replace($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
|
50
app/Http/Requests/Add2FASecretRequest.php
Normal file
50
app/Http/Requests/Add2FASecretRequest.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class Add2FASecretRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
// current logic only updates currently authenticated user
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'otp' => 'required|string|min:6|max:6',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@@ -1,11 +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\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
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -27,8 +45,8 @@ class BanUserRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'reason' => 'required|string',
|
'reason' => 'required|string',
|
||||||
'durationOperand' => 'nullable|integer',
|
'durationOperand' => 'nullable|string',
|
||||||
'durationOperator' => 'nullable|string'
|
'durationOperator' => 'nullable|string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -25,7 +44,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,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -25,7 +44,7 @@ class ChangePasswordRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'newPassword' => 'required|string|confirmed',
|
'newPassword' => 'required|string|confirmed',
|
||||||
'oldPassword' => 'required|string|password'
|
'oldPassword' => 'required|string|password',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -25,7 +44,7 @@ class DeleteUserRequest extends FormRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'confirmPrompt' => 'required|string'
|
'confirmPrompt' => 'required|string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -24,7 +43,7 @@ class FlushSessionsRequest extends FormRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'currentPasswordFlush' => 'required|password'
|
'currentPasswordFlush' => 'required|password',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +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\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
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -27,7 +45,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,10 +1,28 @@
|
|||||||
<?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
|
||||||
{
|
{
|
||||||
@@ -33,7 +51,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',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
app/Http/Requests/Remove2FASecretRequest.php
Normal file
50
app/Http/Requests/Remove2FASecretRequest.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class Remove2FASecretRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'currentPassword' => 'required|password',
|
||||||
|
'consent' => 'required|accepted',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -24,7 +43,7 @@ class SaveNotesRequest extends FormRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'noteText' => 'required|string'
|
'noteText' => 'required|string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -25,7 +44,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,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -28,7 +47,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',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
52
app/Http/Requests/VacancyEditRequest.php
Normal file
52
app/Http/Requests/VacancyEditRequest.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class VacancyEditRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return Auth::user()->can('admin.hiring.vacancy.edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'vacancyDescription' => 'required|string',
|
||||||
|
'vacancyFullDescription' => 'nullable|string',
|
||||||
|
'vacancyCount' => 'required|integer|min:1',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -26,10 +45,11 @@ class VacancyRequest extends FormRequest
|
|||||||
return [
|
return [
|
||||||
'vacancyName' => 'required|string',
|
'vacancyName' => 'required|string',
|
||||||
'vacancyDescription' => 'required|string',
|
'vacancyDescription' => 'required|string',
|
||||||
|
'vacancyFullDescription' => 'nullable|string',
|
||||||
'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,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -24,7 +43,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,7 +1,28 @@
|
|||||||
<?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;
|
||||||
@@ -9,15 +30,12 @@ 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.
|
||||||
*
|
*
|
||||||
@@ -34,23 +52,18 @@ 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,11 +1,28 @@
|
|||||||
<?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
|
||||||
@@ -29,9 +46,8 @@ class DenyUser
|
|||||||
public function handle(ApplicationDeniedEvent $event)
|
public function handle(ApplicationDeniedEvent $event)
|
||||||
{
|
{
|
||||||
$event->application->setStatus('DENIED');
|
$event->application->setStatus('DENIED');
|
||||||
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
61
app/Listeners/LogAuthenticationFailure.php
Normal file
61
app/Listeners/LogAuthenticationFailure.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class LogAuthenticationFailure
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
$targetAccountID = 0;
|
||||||
|
$originalIP = '0.0.0.0';
|
||||||
|
|
||||||
|
if (isset($event->user->id)) {
|
||||||
|
$targetAccountID = $event->user->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::alert('SECURITY (login): Detected failed authentication attempt!', [
|
||||||
|
'targetAccountID' => $targetAccountID,
|
||||||
|
'existingAccount' => ($targetAccountID == 0) ? false : true,
|
||||||
|
'sourceIP' => request()->ip(),
|
||||||
|
'matchesAccountLastIP' => request()->ip() == $originalIP,
|
||||||
|
'sourceUserAgent' => request()->userAgent(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
53
app/Listeners/LogAuthenticationSuccess.php
Normal file
53
app/Listeners/LogAuthenticationSuccess.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class LogAuthenticationSuccess
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
Log::info('SECURITY (postauth-pre2fa): Detected successful login attempt', [
|
||||||
|
'accountID' => $event->user->id,
|
||||||
|
'sourceIP' => request()->ip(),
|
||||||
|
'matchesAccountLastIP' => request()->ip() == $event->user->originalIP,
|
||||||
|
'sourceUserAgent' => request()->userAgent(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,15 +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\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 Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
use App\User;
|
use App\User;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class OnUserBanned
|
class OnUserBanned
|
||||||
{
|
{
|
||||||
@@ -31,16 +46,12 @@ 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!');
|
||||||
|
|
||||||
Log::warning("User " . $event->user->name . " has just been banned from the site!");
|
foreach (User::all() as $user) {
|
||||||
|
if ($user->isStaffMember()) {
|
||||||
foreach(User::all() as $user)
|
$user->notify((new UserBanned($event->user, $event->ban))->delay(now()->addSeconds(10)));
|
||||||
{
|
}
|
||||||
if ($user->isStaffMember())
|
|
||||||
{
|
|
||||||
$user->notify((new UserBanned($event->user, $event->ban))->delay(now()->addSeconds(10)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,14 +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\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
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;
|
use App\Notifications\NewUser;
|
||||||
|
use App\User;
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class OnUserRegistration
|
class OnUserRegistration
|
||||||
{
|
{
|
||||||
@@ -31,12 +47,10 @@ class OnUserRegistration
|
|||||||
public function handle(Registered $event)
|
public function handle(Registered $event)
|
||||||
{
|
{
|
||||||
// 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,13 +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\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\Events\ApplicationApprovedEvent;
|
use App\Events\ApplicationApprovedEvent;
|
||||||
use App\StaffProfile;
|
|
||||||
use App\Notifications\ApplicationApproved;
|
use App\Notifications\ApplicationApproved;
|
||||||
use Carbon\Carbon;
|
use App\StaffProfile;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class PromoteUser
|
class PromoteUser
|
||||||
@@ -35,19 +51,18 @@ 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,9 +1,27 @@
|
|||||||
<?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,17 +1,38 @@
|
|||||||
<?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 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 ApplicationApproved extends Notification implements ShouldQueue
|
class ApplicationApproved extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable, Cancellable;
|
||||||
|
|
||||||
public $application;
|
public $application;
|
||||||
|
|
||||||
@@ -24,15 +45,15 @@ class ApplicationApproved extends Notification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
$this->application = $application;
|
$this->application = $application;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Get the notification's delivery channels.
|
public function channels()
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function via($notifiable)
|
|
||||||
{
|
{
|
||||||
return ['mail', 'slack'];
|
return $this->chooseChannelsViaOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function optOut($notifiable)
|
||||||
|
{
|
||||||
|
return Options::getOption('notify_applicant_approved') !== 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,10 +64,9 @@ 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')
|
||||||
->line('<br />')
|
->line('<br />')
|
||||||
->line('Congratulations! Our Staff team has reviewed your application today, and your application has been approved.')
|
->line('Congratulations! Our Staff team has reviewed your application today, and your application has been approved.')
|
||||||
->line('You have just received the Reviewer role, which allows you to view and vote on other applications.')
|
->line('You have just received the Reviewer role, which allows you to view and vote on other applications.')
|
||||||
@@ -60,19 +80,18 @@ 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());
|
||||||
|
|
||||||
return (new SlackMessage)
|
return (new SlackMessage)
|
||||||
->success()
|
->success()
|
||||||
->content('A user has been approved on the team. Welcome aboard!')
|
->content('A user has been approved on the team. Welcome aboard!')
|
||||||
->attachment(function($attachment) use ($notifiable, $url, $roles){
|
->attachment(function ($attachment) use ($notifiable, $url, $roles) {
|
||||||
$attachment->title('New staff member')
|
$attachment->title('New staff member')
|
||||||
->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,19 +1,37 @@
|
|||||||
<?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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,31 +63,29 @@ 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')
|
||||||
->line('Your most recent application has been denied.')
|
->line('Your most recent application has been denied.')
|
||||||
->line('Our review team denies applications for several reasons, including poor answers.')
|
->line('Our review team denies applications for several reasons, including poor answers.')
|
||||||
->line('Please review your application and try again in 30 days.')
|
->line('Please review your application and try again in 30 days.')
|
||||||
->action('Review application', url(route('showUserApp', ['id' => $this->application->id])))
|
->action('Review application', url(route('showUserApp', ['application' => $this->application->id])))
|
||||||
->line('Better luck next time!');
|
->line('Better luck next time!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function toSlack($notifiable)
|
public function toSlack($notifiable)
|
||||||
{
|
{
|
||||||
$notifiableName = $notifiable->name;
|
$notifiableName = $notifiable->name;
|
||||||
|
|
||||||
return (new SlackMessage)
|
return (new SlackMessage)
|
||||||
->error()
|
->error()
|
||||||
->content('An application has just been denied.')
|
->content('An application has just been denied.')
|
||||||
->attachment(function($attachment) use ($notifiableName){
|
->attachment(function ($attachment) use ($notifiableName) {
|
||||||
$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,7 +1,28 @@
|
|||||||
<?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;
|
||||||
@@ -9,7 +30,7 @@ use Illuminate\Notifications\Notification;
|
|||||||
|
|
||||||
class ApplicationMoved extends Notification implements ShouldQueue
|
class ApplicationMoved extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable, Cancellable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new notification instance.
|
* Create a new notification instance.
|
||||||
@@ -21,15 +42,9 @@ class ApplicationMoved extends Notification implements ShouldQueue
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function optOut($notifiable)
|
||||||
* Get the notification's delivery channels.
|
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function via($notifiable)
|
|
||||||
{
|
{
|
||||||
return ['mail'];
|
return Options::getOption('notify_application_status_change') !== 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +57,7 @@ class ApplicationMoved extends Notification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
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') . ' - Application Updated')
|
->subject(config('app.name').' - Application Updated')
|
||||||
->line('Your most recent application has been moved up a stage.')
|
->line('Your most recent application has been moved up a stage.')
|
||||||
->line('This means our team has reviewed it and an interview will be scheduled ASAP.')
|
->line('This means our team has reviewed it and an interview will be scheduled ASAP.')
|
||||||
->action('Sign in', url(route('login')))
|
->action('Sign in', url(route('login')))
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -42,7 +61,7 @@ class AppointmentFinished extends Notification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
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') . ' - Appointment completed')
|
->subject(config('app.name').' - Appointment completed')
|
||||||
->line('Your appointment has been marked as completed!')
|
->line('Your appointment has been marked as completed!')
|
||||||
->line('Please allow an additional day for your application to be fully processed.')
|
->line('Please allow an additional day for your application to be fully processed.')
|
||||||
->action('View applications', url(route('showUserApps')))
|
->action('View applications', url(route('showUserApps')))
|
||||||
|
@@ -1,19 +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\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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,10 +64,10 @@ class AppointmentScheduled extends Notification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
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') . ' - Interview scheduled')
|
->subject(config('app.name').' - Interview scheduled')
|
||||||
->line('A voice interview has been scheduled for you @ ' . $this->appointment->appointmentDate . '.')
|
->line('A voice interview has been scheduled for you @ '.$this->appointment->appointmentDate.'.')
|
||||||
->line('With the following details: ' . $this->appointment->appointmentDescription)
|
->line('With the following details: '.$this->appointment->appointmentDescription)
|
||||||
->line('This meeting will take place @ ' . $this->appointment->appointmentLocation . '. You will receive an email soon with details on how to join this meeting.')
|
->line('This meeting will take place @ '.$this->appointment->appointmentLocation.'. You will receive an email soon with details on how to join this meeting.')
|
||||||
->line('You are expected to show up at least 5 minutes before the scheduled date.')
|
->line('You are expected to show up at least 5 minutes before the scheduled date.')
|
||||||
->action('Sign in', url(route('login')))
|
->action('Sign in', url(route('login')))
|
||||||
->line('Thank you!');
|
->line('Thank you!');
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -42,7 +61,7 @@ class ChangedPassword extends Notification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
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') . ' - Account password changed')
|
->subject(config('app.name').' - Account password changed')
|
||||||
->line('The password for the account registered to this email address has just been changed.')
|
->line('The password for the account registered to this email address has just been changed.')
|
||||||
->line('If this was not you, please contact an administrator immediately.')
|
->line('If this was not you, please contact an administrator immediately.')
|
||||||
->action('Sign in', url(route('login')))
|
->action('Sign in', url(route('login')))
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?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;
|
||||||
@@ -42,7 +61,7 @@ class EmailChanged extends Notification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
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') . ' - Email address changed')
|
->subject(config('app.name').' - Email address changed')
|
||||||
->line('The email address for your account has just been updated, either by you or an administrator.')
|
->line('The email address for your account has just been updated, either by you or an administrator.')
|
||||||
->action('Sign in', url(route('login')))
|
->action('Sign in', url(route('login')))
|
||||||
->line('Thank you!');
|
->line('Thank you!');
|
||||||
|
@@ -1,23 +1,42 @@
|
|||||||
<?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;
|
|
||||||
|
|
||||||
class NewApplicant extends Notification implements ShouldQueue
|
class NewApplicant extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable, Cancellable;
|
||||||
|
|
||||||
|
|
||||||
protected $application;
|
protected $application;
|
||||||
|
|
||||||
|
|
||||||
protected $vacancy;
|
protected $vacancy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,15 +50,18 @@ class NewApplicant extends Notification implements ShouldQueue
|
|||||||
$this->vacancy = $vacancy;
|
$this->vacancy = $vacancy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function channels()
|
||||||
* Get the notification's delivery channels.
|
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function via($notifiable)
|
|
||||||
{
|
{
|
||||||
return ['slack'];
|
if (Options::getOption('enable_slack_notifications') == 1) {
|
||||||
|
return ['slack'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function optOut($notifiable)
|
||||||
|
{
|
||||||
|
return Options::getOption('notify_new_user') !== 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,37 +74,36 @@ class NewApplicant extends Notification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
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') . ' - New application')
|
->subject(config('app.name').' - New application')
|
||||||
->line('Someone has just applied for a position. Check it out!')
|
->line('Someone has just applied for a position. Check it out!')
|
||||||
->line('You are receiving this because you\'re a staff member at ' . config('app.name') . '.')
|
->line('You are receiving this because you\'re a staff member at '.config('app.name').'.')
|
||||||
->action('View Application', url(route('showUserApp', ['id' => $this->application->id])))
|
->action('View Application', url(route('showUserApp', ['application' => $this->application->id])))
|
||||||
->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;
|
||||||
|
|
||||||
$url = route('showUserApp', ['id' => $this->application->id]);
|
$url = route('showUserApp', ['application' => $this->application->id]);
|
||||||
$applicant = $this->application->user->name;
|
$applicant = $this->application->user->name;
|
||||||
|
|
||||||
return (new SlackMessage)
|
return (new SlackMessage)
|
||||||
->success()
|
->success()
|
||||||
->content('Notice: New application coming through. Please review as soon as possible.')
|
->content('Notice: New application coming through. Please review as soon as possible.')
|
||||||
->attachment(function($attachment) use ($vacancyDetails, $url, $applicant){
|
->attachment(function ($attachment) use ($vacancyDetails, $url, $applicant) {
|
||||||
$attachment->title('Application details')
|
$attachment->title('Application details')
|
||||||
->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.
|
||||||
*
|
*
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user