Skip to content

Commit c189db8

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into allow-null-group-assignment
2 parents 13fa23c + 35ec97c commit c189db8

79 files changed

Lines changed: 798 additions & 815 deletions

File tree

Some content is hidden

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

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ services:
99
- redis-server
1010

1111
php:
12-
- 5.6
13-
- 7
1412
- 7.1
1513
- 7.2
1614
- 7.3

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [v4.3.0]
9+
10+
### Changed Requirements
11+
- Changed minimum PHP Version to 7.1
12+
13+
### Added
14+
- Separated `BakeCommand` class into multiple methods to make it easier for sprinkle to add custom command to the `bake` command.
15+
16+
### Fix
17+
- `bake` command return error if account sprinkle is not included ([#944])
18+
19+
### Changed
20+
- Account sprinkle now extend the Core `BakeCommand` class to add the `create-admin` to the general bake command. Any sprinkle already extending the Core `BakeCommand` might need adjustments.
21+
- Updated custom Eloquent relations (`belongsToManyThrough`, `morphToManyUnique`, `belongsToManyUnique`, `morphToManyUnique`, etc.) to support Laravel 5.8. See [The `belongsToMany` Method](https://laravel.com/docs/5.5/upgrade#upgrade-5.5.0).
22+
23+
### Removed
24+
- Removed `belongsToManyConstrained` (deprecated in 4.1.6)
25+
26+
## [v4.2.3]
27+
28+
### Added
29+
- Config to set Domain of RememberMe Cookie ([#990]; [#991]; Thanks @xrobau!)
30+
- Config settings for password min/max length ([#993])
31+
32+
### Fixed
33+
- [PHPMailer] Turn off opportunistic TLS when disabled ([#986]; [#987])
34+
- Migrator now ignore files that don't end in `.php` ([#965]; Temporary fix for [#998])
35+
836
## [v4.2.2]
937

1038
### Added
@@ -755,10 +783,18 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
755783
[#953]: https://github.com/userfrosting/UserFrosting/issues/953
756784
[#958]: https://github.com/userfrosting/UserFrosting/issues/958
757785
[#963]: https://github.com/userfrosting/UserFrosting/issues/963
786+
[#965]: https://github.com/userfrosting/UserFrosting/issues/965
758787
[#968]: https://github.com/userfrosting/UserFrosting/issues/968
759788
[#981]: https://github.com/userfrosting/UserFrosting/issues/981
760789
[#983]: https://github.com/userfrosting/UserFrosting/issues/983
790+
[#986]: https://github.com/userfrosting/UserFrosting/issues/986
791+
[#987]: https://github.com/userfrosting/UserFrosting/issues/987
792+
[#990]: https://github.com/userfrosting/UserFrosting/issues/990
793+
[#991]: https://github.com/userfrosting/UserFrosting/issues/991
794+
[#993]: https://github.com/userfrosting/UserFrosting/issues/993
795+
[#998]: https://github.com/userfrosting/UserFrosting/issues/998
761796

762797
[v4.2.0]: https://github.com/userfrosting/UserFrosting/compare/v4.1.22...v4.2.0
763798
[v4.2.1]: https://github.com/userfrosting/UserFrosting/compare/v4.2.0...v.4.2.1
764799
[v4.2.2]: https://github.com/userfrosting/UserFrosting/compare/v.4.2.1...v4.2.2
800+
[v4.2.3]: https://github.com/userfrosting/UserFrosting/compare/v4.2.2...v4.2.3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ If you simply want to show that you like this project, or want to remember it fo
3333

3434
Copyright (c) 2019, free to use in personal and commercial software as per the [license](LICENSE.md).
3535

36-
UserFrosting is a secure, modern user management system written in PHP and built on top of the [Slim Microframework](http://www.slimframework.com/), [Twig](http://twig.sensiolabs.org/) templating engine, and [Eloquent](https://laravel.com/docs/5.4/eloquent#introduction) ORM.
36+
UserFrosting is a secure, modern user management system written in PHP and built on top of the [Slim Microframework](http://www.slimframework.com/), [Twig](http://twig.sensiolabs.org/) templating engine, and [Eloquent](https://laravel.com/docs/5.8/eloquent#introduction) ORM.
3737

3838
## Features
3939

app/defines.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
namespace UserFrosting;
1212

1313
// Some standard defines
14-
define('UserFrosting\VERSION', '4.2.2');
14+
define('UserFrosting\VERSION', '4.3.0-dev');
1515
define('UserFrosting\DS', '/');
16-
define('UserFrosting\PHP_MIN_VERSION', '5.6');
16+
define('UserFrosting\PHP_MIN_VERSION', '7.1');
1717
define('UserFrosting\PHP_RECOMMENDED_VERSION', '7.2');
1818
define('UserFrosting\NODE_MIN_VERSION', 'v10.12.0');
1919
define('UserFrosting\NPM_MIN_VERSION', '6.0.0');

app/sprinkles/account/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
],
1414
"require": {
1515
"birke/rememberme" : "^2.0",
16-
"nikic/php-parser" : "^1",
17-
"php": ">=5.6"
16+
"nikic/php-parser" : "^1"
1817
},
1918
"autoload": {
2019
"psr-4": {

app/sprinkles/account/config/default.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,37 @@
5555
* RememberMe Package Settings
5656
* ----------------------------------------------------------------------
5757
* See https://github.com/gbirke/rememberme for an explanation of these settings
58+
*
59+
* Note that the 'domain' field can be set to match your top-level-domain if you
60+
* want to send the rememberme to all hosts in your domain. An automatic config
61+
* of this can be done in your config.php with code similar to this:
62+
*
63+
* if (!empty($_SERVER['SERVER_NAME']) && filter_var($_SERVER['SERVER_NAME'], \FILTER_VALIDATE_IP) === false) {
64+
* $darr = explode(".", $_SERVER['SERVER_NAME']);
65+
* array_shift($darr);
66+
* $conf['session']['cookie_parameters'] = [ "lifetime" => 86400, "domain" => ".".join(".", $darr), "path" => "/" ];
67+
* $conf['remember_me'] = [ "domain" => ".".join(".", $darr) ];
68+
* }
69+
*
70+
* (Or, for production, you can hard-code the domain rather than calculating it on each page load)
71+
*
72+
* This is DELIBERATELY NOT TURNED ON BY DEFAULT!
73+
*
74+
* If you enable the 'domain' (on both the session and the remember_me cookies)
75+
* you will be sending your authentication cookies to every machine in the
76+
* domain you are using. This may not be bad if you control the domain, but
77+
* if you are using a VPS and the hostname of the machine you are connecting to
78+
* is, for example, host2.vps.blah.com, and you connect to host20.vps.blah.com,
79+
* your browser will send your (super secret) cookies to host20.vps.blah.com.
80+
*
81+
* You only want to turn this on if you want machine1.foo.com to receive the
82+
* cookies that THIS MACHINE (machine2.foo.com) set.
5883
*/
5984
'remember_me' => [
6085
'cookie' => [
6186
'name' => 'rememberme',
6287
],
88+
'domain' => null,
6389
'expire_time' => 604800,
6490
'session' => [
6591
'path' => '/',
@@ -96,7 +122,8 @@
96122
* Account Site Settings
97123
* ----------------------------------------------------------------------
98124
* "Site" settings that are automatically passed to Twig. Use theses
99-
* settings to control the login and registration process
125+
* settings to control the login, password (re)set and registration
126+
* processes
100127
*/
101128
'site' => [
102129
'login' => [
@@ -115,6 +142,12 @@
115142
],
116143
],
117144
],
145+
'password' => [
146+
'length' => [
147+
'min' => 8,
148+
'max' => 25,
149+
],
150+
],
118151
],
119152

120153
/*

app/sprinkles/account/locale/es_ES/messages.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
'PASSWORD' => [
100100
'@TRANSLATION' => 'Contraseña',
101101

102-
'BETWEEN' => 'Entre {{min}} - {{max}} (recomendado 12)',
102+
'BETWEEN' => 'Entre {{min}} - {{max}}',
103103

104104
'CONFIRM' => 'Confirmar contraseña',
105105
'CONFIRM_CURRENT' => 'Por favor, confirma tu contraseña actual',

app/sprinkles/account/src/Account/Registration.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function register()
9191
$this->validate();
9292

9393
// Set default group
94-
$defaultGroup = $this->ci->classMapper->staticMethod('group', 'where', 'slug', $this->defaultGroup)->first();
94+
$defaultGroup = $this->ci->classMapper->getClassMapping('group')::where('slug', $this->defaultGroup)->first();
9595

9696
if (!$defaultGroup) {
9797
$e = new HttpException("Account registration is not working because the default group '{$this->defaultGroup}' does not exist.");
@@ -127,7 +127,7 @@ public function register()
127127
]);
128128

129129
// Load default roles
130-
$defaultRoles = $this->ci->classMapper->staticMethod('role', 'whereIn', 'slug', $this->defaultRoles)->get();
130+
$defaultRoles = $this->ci->classMapper->getClassMapping('role')::whereIn('slug', $this->defaultRoles)->get();
131131
$defaultRoleIds = $defaultRoles->pluck('id')->all();
132132

133133
// Attach default roles
@@ -195,7 +195,7 @@ public function validate()
195195
*/
196196
public function usernameIsUnique($username)
197197
{
198-
return !($this->ci->classMapper->staticMethod('user', 'findUnique', $username, 'user_name'));
198+
return !($this->ci->classMapper->getClassMapping('user')::findUnique($username, 'user_name'));
199199
}
200200

201201
/**
@@ -208,7 +208,7 @@ public function usernameIsUnique($username)
208208
*/
209209
public function emailIsUnique($email)
210210
{
211-
return !($this->ci->classMapper->staticMethod('user', 'findUnique', $email, 'email'));
211+
return !($this->ci->classMapper->getClassMapping('user')::findUnique($email, 'email'));
212212
}
213213

214214
/**
@@ -227,7 +227,7 @@ protected function setDefaults()
227227
$this->verified = $this->ci->config['site.registration.require_email_verification'];
228228
$this->requireEmailVerification = $this->ci->config['site.registration.require_email_verification'];
229229
$this->defaultGroup = $this->ci->config['site.registration.user_defaults.group'];
230-
$this->defaultRoles = $this->ci->classMapper->staticMethod('role', 'getDefaultSlugs');
230+
$this->defaultRoles = $this->ci->classMapper->getClassMapping('role')::getDefaultSlugs();
231231
}
232232

233233
/**

app/sprinkles/account/src/Authenticate/Authenticator.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,15 @@ public function __construct(ClassMapper $classMapper, Session $session, Config $
118118
$this->rememberMe->getCookie()->setPath($this->config['remember_me.session.path']);
119119

120120
// Set expire time, if specified
121-
if ($this->config->has('remember_me.expire_time') && ($this->config->has('remember_me.expire_time') != null)) {
121+
if ($this->config->has('remember_me.expire_time') && $this->config->has('remember_me.expire_time') != null) {
122122
$this->rememberMe->getCookie()->setExpireTime($this->config['remember_me.expire_time']);
123123
}
124124

125+
// Set domain, if specified
126+
if ($this->config->has('remember_me.domain') && $this->config->has('remember_me.domain') != null) {
127+
$this->rememberMe->getCookie()->setDomain($this->config['remember_me.domain']);
128+
}
129+
125130
$this->user = null;
126131
$this->viaRemember = false;
127132
}
@@ -145,7 +150,7 @@ public function __construct(ClassMapper $classMapper, Session $session, Config $
145150
public function attempt($identityColumn, $identityValue, $password, $rememberMe = false)
146151
{
147152
// Try to load the user, using the specified conditions
148-
$user = $this->classMapper->staticMethod('user', 'where', $identityColumn, $identityValue)->first();
153+
$user = $this->classMapper->getClassMapping('user')::where($identityColumn, $identityValue)->first();
149154

150155
if (!$user) {
151156
throw new InvalidCredentialsException();
@@ -257,7 +262,7 @@ public function logout($complete = false)
257262

258263
// User logout actions
259264
if ($currentUserId) {
260-
$currentUser = $this->classMapper->staticMethod('user', 'find', $currentUserId);
265+
$currentUser = $this->classMapper->getClassMapping('user')::find($currentUserId);
261266
if ($currentUser) {
262267
$currentUser->onLogout();
263268
}
@@ -425,7 +430,7 @@ protected function validateUserAccount($userId)
425430
// Load user from db, cache the result
426431
$key = $this->config['cache.user.key'] . $userId;
427432
$user = $this->cache->remember($key, $this->config['cache.user.delay'], function () use ($userId) {
428-
return $this->classMapper->staticMethod('user', 'find', (int) $userId);
433+
return $this->classMapper->getClassMapping('user')::find((int) $userId);
429434
});
430435

431436
// If the user doesn't exist any more, throw an exception.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* UserFrosting (http://www.userfrosting.com)
5+
*
6+
* @link https://github.com/userfrosting/UserFrosting
7+
* @copyright Copyright (c) 2019 Alexander Weissman
8+
* @license https://github.com/userfrosting/UserFrosting/blob/master/LICENSE.md (MIT License)
9+
*/
10+
11+
namespace UserFrosting\Sprinkle\Account\Bakery;
12+
13+
use Symfony\Component\Console\Input\InputInterface;
14+
use Symfony\Component\Console\Output\OutputInterface;
15+
use UserFrosting\Sprinkle\Core\Bakery\BakeCommand as CoreBakeCommand;
16+
17+
/**
18+
* Bake command extension.
19+
* Adding Account provided `create-admin` to the bake command.
20+
*/
21+
class BakeCommand extends CoreBakeCommand
22+
{
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
protected function executeConfiguration(InputInterface $input, OutputInterface $output)
27+
{
28+
parent::executeConfiguration($input, $output);
29+
30+
$command = $this->getApplication()->find('create-admin');
31+
$command->run($input, $output);
32+
}
33+
}

0 commit comments

Comments
 (0)