Skip to content

Commit 5b06e30

Browse files
bennothommomjauvin
andauthored
Rebrand User plugin for Winter CMS (#1)
Co-authored-by: Marc Jauvin <[email protected]>
1 parent c9447a9 commit 5b06e30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+623
-547
lines changed

.github/workflows/tests.yml

+14-12
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
strategy:
1414
max-parallel: 6
1515
matrix:
16-
phpVersions: ['7.2', '7.3', '7.4']
16+
phpVersions: ['7.2', '7.3', '7.4', '8.0']
1717
fail-fast: false
1818
env:
1919
phpExtensions: mbstring, intl, gd, xml, sqlite
2020
cacheKey: ext-cache-v1
21-
octoberCmsRelease: develop
21+
winterCmsRelease: develop
2222
steps:
2323
- name: Checkout changes
2424
uses: actions/checkout@v2
@@ -45,19 +45,21 @@ jobs:
4545
with:
4646
php-version: ${{ matrix.phpVersions }}
4747
extensions: ${{ env.phpExtensions }}
48-
tools: composer:v1
48+
tools: composer:v2
4949
coverage: none
5050

51-
- name: Install October CMS
51+
- name: Install Winter CMS
5252
run: |
53-
wget https://github.com/octobercms/october/archive/${{ env.octoberCmsRelease }}.zip
54-
unzip ${{ env.octoberCmsRelease }}.zip
53+
wget https://github.com/wintercms/winter/archive/${{ env.winterCmsRelease }}.zip
54+
unzip ${{ env.winterCmsRelease }}.zip
55+
rm ${{ env.winterCmsRelease }}.zip
5556
shopt -s dotglob
56-
mv october-${{ env.octoberCmsRelease }}/* ./
57+
mv winter-${{ env.winterCmsRelease }}/* ./
58+
rmdir winter-${{ env.winterCmsRelease }}
5759
shopt -u dotglob
5860
cp config/cms.php config/testing/cms.php
59-
mkdir -p plugins/rainlab
60-
mv user-plugin plugins/rainlab/user
61+
mkdir -p plugins/winter
62+
mv user-plugin plugins/winter/user
6163
6264
- name: Get Composer cache directory
6365
id: composercache
@@ -71,12 +73,12 @@ jobs:
7173
restore-keys: ${{ runner.os }}-composer-
7274

7375
- name: Install Composer dependencies
74-
run: composer install --no-interaction --no-progress --no-suggest
76+
run: composer install --no-interaction --no-progress
7577

7678
- name: Run linting
77-
run: ./vendor/bin/parallel-lint plugins/rainlab/user
79+
run: ./vendor/bin/parallel-lint plugins/winter/user
7880

7981
- name: Run unit tests
8082
run: |
81-
cd plugins/rainlab/user
83+
cd plugins/winter/user
8284
../../../vendor/bin/phpunit

Plugin.php

+56-51
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace RainLab\User;
1+
<?php namespace Winter\User;
22

33
use App;
44
use Auth;
@@ -7,9 +7,9 @@
77
use System\Classes\PluginBase;
88
use System\Classes\SettingsManager;
99
use Illuminate\Foundation\AliasLoader;
10-
use RainLab\User\Classes\UserRedirector;
11-
use RainLab\User\Models\MailBlocker;
12-
use RainLab\Notify\Classes\Notifier;
10+
use Winter\User\Classes\UserRedirector;
11+
use Winter\User\Models\MailBlocker;
12+
use Winter\Notify\Classes\Notifier;
1313

1414
class Plugin extends PluginBase
1515
{
@@ -21,21 +21,22 @@ class Plugin extends PluginBase
2121
public function pluginDetails()
2222
{
2323
return [
24-
'name' => 'rainlab.user::lang.plugin.name',
25-
'description' => 'rainlab.user::lang.plugin.description',
24+
'name' => 'winter.user::lang.plugin.name',
25+
'description' => 'winter.user::lang.plugin.description',
2626
'author' => 'Alexey Bobkov, Samuel Georges',
2727
'icon' => 'icon-user',
28-
'homepage' => 'https://github.com/rainlab/user-plugin'
28+
'homepage' => 'https://github.com/wintercms/wn-user-plugin',
29+
'replaces' => 'RainLab.User'
2930
];
3031
}
3132

3233
public function register()
3334
{
3435
$alias = AliasLoader::getInstance();
35-
$alias->alias('Auth', 'RainLab\User\Facades\Auth');
36+
$alias->alias('Auth', 'Winter\User\Facades\Auth');
3637

3738
App::singleton('user.auth', function () {
38-
return \RainLab\User\Classes\AuthManager::instance();
39+
return \Winter\User\Classes\AuthManager::instance();
3940
});
4041

4142
App::singleton('redirect', function ($app) {
@@ -61,38 +62,38 @@ public function register()
6162
});
6263

6364
/*
64-
* Compatability with RainLab.Notify
65+
* Compatability with Winter.Notify
6566
*/
6667
$this->bindNotificationEvents();
6768
}
6869

6970
public function registerComponents()
7071
{
7172
return [
72-
\RainLab\User\Components\Session::class => 'session',
73-
\RainLab\User\Components\Account::class => 'account',
74-
\RainLab\User\Components\ResetPassword::class => 'resetPassword'
73+
\Winter\User\Components\Session::class => 'session',
74+
\Winter\User\Components\Account::class => 'account',
75+
\Winter\User\Components\ResetPassword::class => 'resetPassword'
7576
];
7677
}
7778

7879
public function registerPermissions()
7980
{
8081
return [
81-
'rainlab.users.access_users' => [
82-
'tab' => 'rainlab.user::lang.plugin.tab',
83-
'label' => 'rainlab.user::lang.plugin.access_users'
82+
'winter.users.access_users' => [
83+
'tab' => 'winter.user::lang.plugin.tab',
84+
'label' => 'winter.user::lang.plugin.access_users'
8485
],
85-
'rainlab.users.access_groups' => [
86-
'tab' => 'rainlab.user::lang.plugin.tab',
87-
'label' => 'rainlab.user::lang.plugin.access_groups'
86+
'winter.users.access_groups' => [
87+
'tab' => 'winter.user::lang.plugin.tab',
88+
'label' => 'winter.user::lang.plugin.access_groups'
8889
],
89-
'rainlab.users.access_settings' => [
90-
'tab' => 'rainlab.user::lang.plugin.tab',
91-
'label' => 'rainlab.user::lang.plugin.access_settings'
90+
'winter.users.access_settings' => [
91+
'tab' => 'winter.user::lang.plugin.tab',
92+
'label' => 'winter.user::lang.plugin.access_settings'
9293
],
93-
'rainlab.users.impersonate_user' => [
94-
'tab' => 'rainlab.user::lang.plugin.tab',
95-
'label' => 'rainlab.user::lang.plugin.impersonate_user'
94+
'winter.users.impersonate_user' => [
95+
'tab' => 'winter.user::lang.plugin.tab',
96+
'label' => 'winter.user::lang.plugin.impersonate_user'
9697
],
9798
];
9899
}
@@ -101,25 +102,25 @@ public function registerNavigation()
101102
{
102103
return [
103104
'user' => [
104-
'label' => 'rainlab.user::lang.users.menu_label',
105-
'url' => Backend::url('rainlab/user/users'),
105+
'label' => 'winter.user::lang.users.menu_label',
106+
'url' => Backend::url('winter/user/users'),
106107
'icon' => 'icon-user',
107-
'iconSvg' => 'plugins/rainlab/user/assets/images/user-icon.svg',
108-
'permissions' => ['rainlab.users.*'],
108+
'iconSvg' => 'plugins/winter/user/assets/images/user-icon.svg',
109+
'permissions' => ['winter.users.*'],
109110
'order' => 500,
110111

111112
'sideMenu' => [
112113
'users' => [
113-
'label' => 'rainlab.user::lang.users.menu_label',
114+
'label' => 'winter.user::lang.users.menu_label',
114115
'icon' => 'icon-user',
115-
'url' => Backend::url('rainlab/user/users'),
116-
'permissions' => ['rainlab.users.access_users']
116+
'url' => Backend::url('winter/user/users'),
117+
'permissions' => ['winter.users.access_users']
117118
],
118119
'usergroups' => [
119-
'label' => 'rainlab.user::lang.groups.menu_label',
120+
'label' => 'winter.user::lang.groups.menu_label',
120121
'icon' => 'icon-users',
121-
'url' => Backend::url('rainlab/user/usergroups'),
122-
'permissions' => ['rainlab.users.access_groups']
122+
'url' => Backend::url('winter/user/usergroups'),
123+
'permissions' => ['winter.users.access_groups']
123124
]
124125
]
125126
]
@@ -130,31 +131,35 @@ public function registerSettings()
130131
{
131132
return [
132133
'settings' => [
133-
'label' => 'rainlab.user::lang.settings.menu_label',
134-
'description' => 'rainlab.user::lang.settings.menu_description',
134+
'label' => 'winter.user::lang.settings.menu_label',
135+
'description' => 'winter.user::lang.settings.menu_description',
135136
'category' => SettingsManager::CATEGORY_USERS,
136137
'icon' => 'icon-cog',
137-
'class' => 'RainLab\User\Models\Settings',
138+
'class' => 'Winter\User\Models\Settings',
138139
'order' => 500,
139-
'permissions' => ['rainlab.users.access_settings']
140+
'permissions' => ['winter.users.access_settings']
140141
]
141142
];
142143
}
143144

144145
public function registerMailTemplates()
145146
{
146147
return [
147-
'rainlab.user::mail.activate',
148-
'rainlab.user::mail.welcome',
149-
'rainlab.user::mail.restore',
150-
'rainlab.user::mail.new_user',
151-
'rainlab.user::mail.reactivate',
152-
'rainlab.user::mail.invite',
148+
'winter.user::mail.activate',
149+
'winter.user::mail.welcome',
150+
'winter.user::mail.restore',
151+
'winter.user::mail.new_user',
152+
'winter.user::mail.reactivate',
153+
'winter.user::mail.invite',
153154
];
154155
}
155156

156157
public function registerNotificationRules()
157158
{
159+
if (!class_exists(\Winter\Notify\Classes\Notifier::class)) {
160+
return [];
161+
}
162+
158163
return [
159164
'groups' => [
160165
'user' => [
@@ -163,25 +168,25 @@ public function registerNotificationRules()
163168
],
164169
],
165170
'events' => [
166-
\RainLab\User\NotifyRules\UserActivatedEvent::class,
167-
\RainLab\User\NotifyRules\UserRegisteredEvent::class,
171+
\Winter\User\NotifyRules\UserActivatedEvent::class,
172+
\Winter\User\NotifyRules\UserRegisteredEvent::class,
168173
],
169174
'actions' => [],
170175
'conditions' => [
171-
\RainLab\User\NotifyRules\UserAttributeCondition::class
176+
'Winter\User\NotifyRules\UserAttributeCondition',
172177
],
173178
];
174179
}
175180

176181
protected function bindNotificationEvents()
177182
{
178-
if (!class_exists(Notifier::class)) {
183+
if (!class_exists(\Winter\Notify\Classes\Notifier::class)) {
179184
return;
180185
}
181186

182187
Notifier::bindEvents([
183-
'rainlab.user.activate' => \RainLab\User\NotifyRules\UserActivatedEvent::class,
184-
'rainlab.user.register' => \RainLab\User\NotifyRules\UserRegisteredEvent::class
188+
'winter.user.activate' => \Winter\User\NotifyRules\UserActivatedEvent::class,
189+
'winter.user.register' => \Winter\User\NotifyRules\UserRegisteredEvent::class,
185190
]);
186191

187192
Notifier::instance()->registerCallback(function ($manager) {

README.md

+23-27
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Front-end user plugin
22

3-
[![Build Status](https://img.shields.io/github/workflow/status/rainlab/user-plugin/Tests)](https://github.com/rainlab/user-plugin/actions)
4-
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/rainlab/user-plugin/blob/master/LICENCE.md)
3+
[![Build Status](https://img.shields.io/github/workflow/status/wintercms/wn-user-plugin/Tests)](https://github.com/wintercms/wn-user-plugin/actions)
4+
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/wintercms/wn-user-plugin/blob/master/LICENCE.md)
55

6-
Front-end user management for October CMS.
6+
Front-end user management for Winter CMS.
77

88
## Requirements
99

10-
This plugin requires the [Ajax Framework](https://octobercms.com/docs/cms/ajax) to be included in your layout/page in order to handle form requests.
10+
This plugin requires the [Ajax Framework](https://wintercms.com/docs/cms/ajax) to be included in your layout/page in order to handle form requests.
1111

1212
## Managing users
1313

@@ -47,11 +47,7 @@ As a security precaution, you may restrict users from having sessions across mul
4747

4848
#### Notifications
4949

50-
When a user is first activated -- either by registration, email confirmation or administrator approval -- they are sent a welcome email. To disable the welcome email, select "Do not send a notification" from the **Welcome mail template** dropdown. The default message template used is `rainlab.user::mail.welcome` and you can customize this by selecting **Mail > Mail Templates** from the settings menu.
51-
52-
## Extended features
53-
54-
For extra functionality, consider also installing the [User Plus+ plugin](http://octobercms.com/plugin/rainlab-userplus) (`RainLab.UserPlus`).
50+
When a user is first activated -- either by registration, email confirmation or administrator approval -- they are sent a welcome email. To disable the welcome email, select "Do not send a notification" from the **Welcome mail template** dropdown. The default message template used is `winter.user::mail.welcome` and you can customize this by selecting **Mail > Mail Templates** from the settings menu.
5551

5652
## Session component
5753

@@ -90,7 +86,7 @@ The `security` property can be user, guest or all. The `redirect` property refer
9086

9187
Access to routes can be restricted by applying the `AuthMiddleware`.
9288

93-
Route::group(['middleware' => 'RainLab\User\Classes\AuthMiddleware'], function () {
89+
Route::group(['middleware' => 'Winter\User\Classes\AuthMiddleware'], function () {
9490
// All routes here will require authentication
9591
});
9692

@@ -153,7 +149,7 @@ By default, the User plugin requires a minimum password length of 8 characters f
153149

154150
### Flash messages
155151

156-
This plugin makes use of October's [`Flash API`](http://octobercms.com/docs/markup/tag-flash). In order to display the error messages, you need to place the following snippet in your layout or page.
152+
This plugin makes use of Winter CMS's [`Flash API`](https://wintercms.com/docs/markup/tag-flash). In order to display the error messages, you need to place the following snippet in your layout or page.
157153

158154
{% flash %}
159155
<div class="alert alert-{{ type == 'error' ? 'danger' : type }}">{{ message }}</div>
@@ -219,7 +215,7 @@ Here the local handler method will take priority over the **account** component'
219215

220216
## Auth facade
221217

222-
There is an `Auth` facade you may use for common tasks, it primarily inherits the `October\Rain\Auth\Manager` class for functionality.
218+
There is an `Auth` facade you may use for common tasks, it primarily inherits the `Winter\Storm\Auth\Manager` class for functionality.
223219

224220
You may use `Auth::register` to register an account:
225221

@@ -290,7 +286,7 @@ When a user registers with the same email address using the `Auth::register` met
290286

291287
> **Important**: If you are using guest accounts, it is important to disable sensitive functionality for user accounts that are not verified, since it may be possible for anyone to inherit a guest account.
292288
293-
You may also convert a guest to a registered user with the `convertToRegistered` method. This will generate a random password and sends an invitation using the `rainlab.user::mail.invite` template.
289+
You may also convert a guest to a registered user with the `convertToRegistered` method. This will generate a random password and sends an invitation using the `winter.user::mail.invite` template.
294290

295291
$user->convertToRegistered();
296292

@@ -302,26 +298,26 @@ To disable the notification and password reset, pass the first argument as false
302298

303299
This plugin will fire some global events that can be useful for interacting with other plugins.
304300

305-
- **rainlab.user.beforeRegister**: Before the user's registration is processed. Passed the `$data` variable by reference to enable direct modifications to the `$data` provided to the `Auth::register()` method.
306-
- **rainlab.user.register**: The user has successfully registered. Passed the `$user` object and the submitted `$data` variable.
307-
- **rainlab.user.beforeAuthenticate**: Before the user is attempting to authenticate using the Account component.
308-
- **rainlab.user.login**: The user has successfully signed in.
309-
- **rainlab.user.logout**: The user has successfully signed out.
310-
- **rainlab.user.deactivate**: The user has opted-out of the site by deactivating their account. This should be used to disable any content the user may want removed.
311-
- **rainlab.user.reactivate**: The user has reactivated their own account by signing back in. This should revive the users content on the site.
312-
- **rainlab.user.getNotificationVars**: Fires when sending a user notification to enable passing more variables to the email templates. Passes the `$user` model the template will be for.
313-
- **rainlab.user.view.extendListToolbar**: Fires when the user listing page's toolbar is rendered.
314-
- **rainlab.user.view.extendPreviewToolbar**: Fires when the user preview page's toolbar is rendered.
301+
- **winter.user.beforeRegister**: Before the user's registration is processed. Passed the `$data` variable by reference to enable direct modifications to the `$data` provided to the `Auth::register()` method.
302+
- **winter.user.register**: The user has successfully registered. Passed the `$user` object and the submitted `$data` variable.
303+
- **winter.user.beforeAuthenticate**: Before the user is attempting to authenticate using the Account component.
304+
- **winter.user.login**: The user has successfully signed in.
305+
- **winter.user.logout**: The user has successfully signed out.
306+
- **winter.user.deactivate**: The user has opted-out of the site by deactivating their account. This should be used to disable any content the user may want removed.
307+
- **winter.user.reactivate**: The user has reactivated their own account by signing back in. This should revive the users content on the site.
308+
- **winter.user.getNotificationVars**: Fires when sending a user notification to enable passing more variables to the email templates. Passes the `$user` model the template will be for.
309+
- **winter.user.view.extendListToolbar**: Fires when the user listing page's toolbar is rendered.
310+
- **winter.user.view.extendPreviewToolbar**: Fires when the user preview page's toolbar is rendered.
315311

316312
Here is an example of hooking an event:
317313

318-
Event::listen('rainlab.user.deactivate', function($user) {
314+
Event::listen('winter.user.deactivate', function($user) {
319315
// Hide all posts by the user
320316
});
321317

322-
A common requirement is to adapt another to a legacy authentication system. In the example below, the `WordPressLogin::check` method would check the user password using an alternative hashing method, and if successful, update to the new one used by October.
318+
A common requirement is to adapt another to a legacy authentication system. In the example below, the `WordPressLogin::check` method would check the user password using an alternative hashing method, and if successful, update to the new one used by Winter CMS.
323319

324-
Event::listen('rainlab.user.beforeAuthenticate', function($component, $credentials) {
320+
Event::listen('winter.user.beforeAuthenticate', function($component, $credentials) {
325321
$login = array_get($credentials, 'login');
326322
$password = array_get($credentials, 'password');
327323

@@ -335,7 +331,7 @@ A common requirement is to adapt another to a legacy authentication system. In t
335331
/*
336332
* The user is logging in with their old WordPress account
337333
* for the first time. Rehash their password using the new
338-
* October system.
334+
* Winter CMS system.
339335
*/
340336
if (WordPressLogin::check($user->password, $password)) {
341337
$user->password = $user->password_confirmation = $password;

0 commit comments

Comments
 (0)