Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit 2668729

Browse files
authored
Specify allowed domains (#81)
* Specify allowed domains * Apply fixes from StyleCI (#80) [ci skip] [skip ci] * Add tests * Apply fixes from StyleCI (#82) [ci skip] [skip ci]
1 parent 58748b2 commit 2668729

22 files changed

Lines changed: 9581 additions & 51 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ clover.xml
44
coverage/
55
node_modules/
66
package-lock.json
7+
yarn.lock
78
vendor/

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
"statamic/cms": "^3.1"
2626
},
2727
"require-dev": {
28+
"nunomaduro/larastan": "^0.7.6",
2829
"orchestra/testbench": "^6.18.0",
29-
"phpunit/phpunit": "^9.5"
30+
"phpunit/phpunit": "^9.5",
31+
"spatie/ray": "^1.26"
3032
},
3133
"config": {
3234
"process-timeout": 0,

package.json

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
{
2-
"private": true,
3-
"scripts": {
4-
"dev": "npm run development",
5-
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6-
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
7-
"watch-poll": "npm run watch -- --watch-poll",
8-
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9-
"prod": "npm run production",
10-
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
11-
},
12-
"devDependencies": {
13-
"cross-env": "^5.1",
14-
"laravel-mix": "^5.0.9",
15-
"laravel-mix-purgecss": "^4.2.0",
16-
"node-forge": ">=0.10.0",
17-
"postcss-import": "^14.0.0",
18-
"postcss-nested": "^5.0.5",
19-
"postcss-preset-env": "^6.7.0",
20-
"vue-template-compiler": "^2.6.12"
21-
},
22-
"dependencies": {
23-
"axios": "^0.21.0",
24-
"tailwindcss": "^2.0.3"
25-
}
2+
"private": true,
3+
"scripts": {
4+
"dev": "mix",
5+
"development": "mix",
6+
"watch": "mix watch",
7+
"watch-poll": "mix watch -- --watch-options-poll=1000",
8+
"hot": "mix watch --hot",
9+
"production": "mix --production"
10+
},
11+
"devDependencies": {
12+
"autoprefixer": "^10.2.6",
13+
"axios": "^0.21.1",
14+
"browser-sync": "^2.26.14",
15+
"browser-sync-webpack-plugin": "^2.3.0",
16+
"cross-env": "^7.0.3",
17+
"laravel-mix": "^6.0.19",
18+
"postcss": "^8.3.0",
19+
"postcss-focus-visible": "^3.0.0",
20+
"postcss-import": "^14.0.2",
21+
"postcss-nested": "^5.0.5",
22+
"resolve-url-loader": "^4.0.0",
23+
"tailwindcss": "^2.1.2",
24+
"vue-loader": "^15.9.5",
25+
"vue-template-compiler": "^2.6.12"
26+
},
27+
"dependencies": {}
2628
}

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- ./vendor/nunomaduro/larastan/extension.neon
3+
4+
parameters:
5+
level: 1
6+
paths:
7+
- src
8+
- tests

public/css/statamic-magiclink.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

public/js/statamic-magiclink.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import SendMagicLinkComponent from './components/SendMagicLinkComponent';
22
import SettingsComponent from './components/SettingsComponent';
33
import LinksListingComponent from './components/Links/ListingComponent';
44

5+
window.axios = require('axios');
6+
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
7+
58
Statamic.booting(() => {
69
Statamic.$components.register('magiclink-settings', SettingsComponent);
710
Statamic.$components.register('magiclink-send-link', SendMagicLinkComponent);

resources/js/components/SettingsComponent.vue

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</div>
3939

4040
<publish-fields-container class="card p-0 mb-3 configure-section">
41-
<div v-for="(address, index) in countAddresses">
41+
<div v-for="(a, index) in countAddresses">
4242
<form-group
4343
class="border-b"
4444
handle="allowedAddresses[]"
@@ -50,6 +50,28 @@
5050
</div>
5151
</publish-fields-container>
5252

53+
<div class="mb-1 content">
54+
<h2 class="text-base">
55+
{{ __('magiclink::cp.settings.ml_allowed_domains') }}
56+
<button class="btn-sm" @click="addDomain">
57+
+ Add new domain
58+
</button>
59+
</h2>
60+
</div>
61+
62+
<publish-fields-container class="card p-0 mb-3 configure-section">
63+
<div v-for="(d, index) in countDomains">
64+
<form-group
65+
class="border-b"
66+
handle="allowedDomains[]"
67+
:display="__('magiclink::cp.settings.ml_allowed_domains')"
68+
:errors="errors.allowedDomains"
69+
:instructions="__('magiclink::cp.settings.ml_allowed_domains_instructions')"
70+
v-model="allowedDomains[index]"
71+
/>
72+
</div>
73+
</publish-fields-container>
74+
5375
<div class="py-2 mt-3 border-t flex justify-between">
5476
<a :href="indexUrl" class="btn" v-text="__('Cancel') "/>
5577
<button type="submit" class="btn-primary" @click="save">{{ __('Save') }}</button>
@@ -63,6 +85,7 @@
6385
props: {
6486
action: String,
6587
initialAllowedAddresses: Array,
88+
initialAllowedDomains: Array,
6689
initialExpireTime: {
6790
type: Number,
6891
required: true,
@@ -85,6 +108,8 @@
85108
return {
86109
allowedAddresses: this.initialAllowedAddresses,
87110
countAddresses: this.initialAllowedAddresses.length + 1,
111+
allowedDomains: this.initialAllowedDomains,
112+
countDomains: this.initialAllowedDomains.length + 1,
88113
error: null,
89114
errors: {},
90115
enabled: this.initialEnabled,
@@ -100,6 +125,7 @@
100125
payload() {
101126
return {
102127
allowedAddresses: this.allowedAddresses,
128+
allowedDomains: this.allowedDomains,
103129
enabled: this.enabled,
104130
expireTime: this.expireTime,
105131
}
@@ -116,6 +142,10 @@
116142
this.countAddresses += 1;
117143
},
118144
145+
addDomain() {
146+
this.countDomains += 1;
147+
},
148+
119149
save() {
120150
this.clearErrors();
121151

resources/lang/de/cp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'ml_enabled' => 'MagicLink aktivieren?',
1010
'ml_enabled_instructions' => 'Aktiviere oder deaktiviere die Nutzung von MagicLinks',
1111
'ml_expire_time' => 'Ablaufzeit',
12-
'ml_expire_time_instructions' => 'Laufzeit des Links, nachdem er verfällt. Standart sind 30 Minuten.',
12+
'ml_expire_time_instructions' => 'Laufzeit des Links, nachdem er verfällt. Standard sind 30 Minuten.',
1313
'updated_successfully' => 'Einstellungen erfolgreich aktualisiert.',
1414
],
1515
'permissions' => [

resources/lang/en/cp.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
'ml_expire_time_instructions' => 'Time the login link is valid. Default is 30 minutes.',
2020
'ml_allowed_addresses' => 'Allowed addresses',
2121
'ml_allowed_addresses_instructions' => 'Allowed addresses to request a magic link for viewing protected content. Enter one address in each field.',
22+
'ml_allowed_domains' => 'Allowed domains',
23+
'ml_allowed_domains_instructions' => 'Allowed domains to request a magic link for. _Example:_ example.com',
2224
'settings' => 'Settings',
2325
'updated_successfully' => 'Settings updated successfully.',
2426
],

0 commit comments

Comments
 (0)