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

Commit 3fee177

Browse files
author
Holger Lösken
committed
Display links in CP
- Show all magic links created in CP - Provide permission scheme
1 parent 645944c commit 3fee177

20 files changed

Lines changed: 1115 additions & 52 deletions

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
A Statamic V3 addon to provide the option to login into the Control Panel or Statamic [Protected Content](https://statamic.dev/protecting-content) feature without using a password,
88
instead use a magic link which is sent by email.
99

10+
**Features**
11+
* Login to Control Panel with magic links
12+
* Login to protected content with custom password form with magic links
13+
* Display issued magic links in Control Panel
14+
* Permission scheme for display links and settings in Control Panel
15+
1016
# Installation
1117

1218
Run the following the pull in the package with composer:

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
},
2222
"require": {
2323
"php": "^7.4",
24+
"ext-json": "*",
2425
"statamic/cms": "3.0.*"
2526
},
2627
"require-dev": {

public/js/statamic-magiclink.js

Lines changed: 907 additions & 1 deletion
Large diffs are not rendered by default.

resources/js/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import SendMagicLinkComponent from './components/SendMagicLinkComponent';
22
import SettingsComponent from './components/SettingsComponent';
3+
import LinksListingComponent from './components/Links/ListingComponent';
34

45
Statamic.booting(() => {
56
Statamic.$components.register('magiclink-settings', SettingsComponent);
67
Statamic.$components.register('magiclink-send-link', SendMagicLinkComponent);
8+
9+
Statamic.$components.register('magiclink-links-listing', LinksListingComponent);
710
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<template>
2+
<data-list :columns="columns" :sort="false" :rows="rows">
3+
<div class="card p-0" slot-scope="{ filteredRows: rows }">
4+
<data-list-table :rows="rows">
5+
<template slot="cell-id" slot-scope="{ row: collection }">
6+
<a :href="collection.show_url">{{ collection.id }}</a>
7+
</template>
8+
</data-list-table>
9+
</div>
10+
</data-list>
11+
</template>
12+
13+
<script>
14+
export default {
15+
props: [
16+
'initial-rows',
17+
'columns',
18+
],
19+
data() {
20+
return {
21+
rows: this.initialRows
22+
}
23+
}
24+
}
25+
</script>

resources/lang/de/cp.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
'view_settings_description' => 'Zugriff, um Einstellungen anzusehen.',
1919
],
2020
'email' => [
21+
'email' => 'E-Mail',
2122
'new_link_subject' => 'Ihr Login-Link',
2223
],
2324

resources/lang/en/cp.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,31 @@
33
declare(strict_types=1);
44

55
return [
6+
'links' => [
7+
'links' => 'Links',
8+
'redirect_to' => 'Redirect to',
9+
'expire_time' => 'Expire time',
10+
'no_links' => 'No links created yet.',
11+
],
612
'settings' => [
713
'headline' => 'MagicLink',
814
'configure_your_needs' => 'Configure MagicLink after your needs.',
915
'ml_enabled' => 'MagicLink enabled?',
1016
'ml_enabled_instructions' => 'Activate or deactivate the usage of magic links.',
1117
'ml_expire_time' => 'Expire time',
1218
'ml_expire_time_instructions' => 'Time the login link is valid. Default is 30 minutes.',
19+
'settings' => 'Settings',
1320
'updated_successfully' => 'Settings updated successfully.',
1421
],
1522
'permissions' => [
1623
'settings' => 'MagicLink Settings',
24+
'view_links' => 'View links',
25+
'view_links_description' => 'Grants access to see magic links',
1726
'view_settings' => 'View settings',
1827
'view_settings_description' => 'Grants access to see settings',
1928
],
2029
'email' => [
30+
'email' => 'Email',
2131
'new_link_subject' => 'Your login link',
2232
],
2333

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@extends('statamic::layout')
2+
@section('title', Statamic::crumb(__('magiclink::cp.links.links'), __('MagicLink')))
3+
4+
@section('content')
5+
<header class="mb-3">
6+
<h1 class="flex-1">{{ __('magiclink::cp.links.links') }}</h1>
7+
<p class="text-sm text-grey mb-2">
8+
</p>
9+
</header>
10+
11+
@unless($links->isEmpty())
12+
13+
<magiclink-links-listing
14+
:initial-rows="{{ json_encode($links) }}"
15+
:columns="{{ json_encode($columns) }}"
16+
:endpoints="{}">
17+
></magiclink-links-listing>
18+
19+
@else
20+
21+
<div class="card">
22+
{{ __('magiclink::cp.links.no_links') }}
23+
</div>
24+
25+
@endunless
26+
@endsection

resources/views/cp/settings/index.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@extends('statamic::layout')
2-
@section('title', 'MagicLink')
2+
@section('title', Statamic::crumb(__('magiclink::cp.settings.settings'), __('MagicLink')))
33

44
@section('content')
55
<header class="mb-3">

routes/cp.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
use Illuminate\Support\Facades\Route;
55

66
Route::prefix('magiclink/')->name('magiclink.')->group(function () {
7+
// Settings
78
Route::get('/', [SettingsController::class, 'index'])->name('index');
89
Route::patch('/update', [SettingsController::class, 'update'])->name('update');
10+
11+
// Links
12+
Route::resource('links', 'Cp\LinksController')->only(['index', 'delete']);
913
});

0 commit comments

Comments
 (0)