Skip to content

Commit

Permalink
Merge branch 'master' into marketplace
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Extend/Marketplace.php
#	tests/Fakes/Composer/Composer.php
  • Loading branch information
jasonvarga committed Jun 1, 2020
2 parents 34695e9 + 538fb3f commit 33c736f
Show file tree
Hide file tree
Showing 112 changed files with 1,442 additions and 370 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"league/glide": "^1.1",
"pixelfear/composer-dist-plugin": "^0.1.0",
"scrumpy/html-to-prosemirror": "^0.6.0",
"scrumpy/prosemirror-to-html": "^0.8.0",
"scrumpy/prosemirror-to-html": "^0.9.0",
"spatie/blink": "^1.1.2",
"statamic/stringy": "^3.1",
"symfony/var-exporter": "^4.3",
Expand Down
16 changes: 16 additions & 0 deletions config/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,20 @@
//
],

/*
|--------------------------------------------------------------------------
| Password Brokers
|--------------------------------------------------------------------------
|
| When resetting passwords, Statamic uses an appropriate password broker.
| Here you may define which broker should be used for each situation.
| You may want a longer expiry for user activations, for example.
|
*/

'passwords' => [
'resets' => config('auth.defaults.passwords'),
'activations' => config('auth.defaults.passwords'),
],

];
6 changes: 2 additions & 4 deletions resources/js/components/fieldtypes/TemplateFieldtype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:name="name"
@input="update"
:clearable="config.clearable"
:placeholder="config.placeholder"
:disabled="isReadOnly"
:options="options"
:reduce="selection => selection.value"
Expand Down Expand Up @@ -40,10 +41,7 @@ export default {
}
// Set default
var options = [{
label: __('Inherit (Default)'),
value: null
}];
var options = [];
_.each(templates, function(template) {
options.push({
Expand Down
16 changes: 8 additions & 8 deletions resources/js/components/modals/KeyboardShortcutsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@
<h1 class="p-2 bg-grey-20 border-b text-center">
{{ __('Keyboard Shortcuts') }}
</h1>
<div class="p-4 relative">
<div class="p-3 relative">
<div class="shortcut-pair">
<span class="shortcut-key">
<span class="shortcut-combo">
<span class="shortcut">shift</span><span class="shortcut-joiner">+</span><span class="shortcut">?</span>
</span>
<span class="shortcut-value">{{ __('Show Keyboard Shortcuts') }}</span>
</div>

<div class="shortcut-pair">
<span class="shortcut-key">
<span class="shortcut-combo">
<span class="shortcut">/</span> <span class="shortcut-joiner">or</span>
<span class="shortcut">ctrl</span><span class="shortcut-joiner">+</span><span class="shortcut">f</span>
</span>
<span class="shortcut-value">{{ __('Focus Search') }}</span>
</div>

<div class="shortcut-pair">
<span class="shortcut-key">
<span class="shortcut">cmd</span><span class="shortcut-joiner">+</span><span class="shortcut">s</span>
<span class="shortcut-combo">
<span class="shortcut"></span><span class="shortcut-joiner">+</span><span class="shortcut">s</span>
</span>
<span class="shortcut-value">{{ __('Save Content') }}</span>
</div>

<div class="shortcut-pair">
<span class="shortcut-key">
<span class="shortcut">cmd</span><span class="shortcut-joiner">+</span><span class="shortcut">\</span>
<span class="shortcut-combo">
<span class="shortcut"></span><span class="shortcut-joiner">+</span><span class="shortcut">\</span>
</span>
<span class="shortcut-value">{{ __('Toggle Sidebar') }}</span>
</div>

<div class="shortcut-pair mb-0">
<span class="shortcut-key">
<span class="shortcut-combo">
<span class="shortcut">esc</span>
</span>
<span class="shortcut-value">{{ __('Close Modal') }}</span>
Expand Down
59 changes: 29 additions & 30 deletions resources/lang/en/messages.php

Large diffs are not rendered by default.

34 changes: 16 additions & 18 deletions resources/sass/components/shortcuts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,32 @@
========================================================================== */

.shortcut-pair {
@apply mb-2 antialiased flex items-center;
@apply pb-1 mb-1 antialiased flex items-center justify-between;
&:not(:last-child) {
@apply border-b;
}
}

.shortcut {
@apply bg-white text-2xs rounded border border-grey-40 inline-block align-middle text-grey-80 text-center;
border-width: 1px 2px 2px 1px;
min-width: 28px;
padding: 3px 4px;
@apply flex items-center justify-center text-3xs;
border-radius: 3px;
background: linear-gradient(-225deg,#d5dbe4,#f8f8f8);
box-shadow: inset 0 -2px 0 0 #cdcde6, inset 0 0 1px 1px #fff, 0 1px 2px 1px rgba(30,35,90,.4);
color: #8d949e;
min-width: 18px;
height: 18px;
margin: 0 .25em;
padding: 0 2px 2px 2px;
}

.shortcut-key {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 70%;
margin-right: 15px;
float: left;
.shortcut-combo {
@apply flex order-2;
}

.shortcut-joiner {
@apply text-grey text-xs mx-sm;
}

.shortcut-value {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: block;
padding: 4px 0;
font-size: 16px;
@apply whitespace-no-wrap py-sm text-sm;
}
4 changes: 2 additions & 2 deletions resources/sass/elements/tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
}
}

.mode-table .data-list-bulk-actions {
.data-list-bulk-actions {
@apply bg-white absolute w-full pt-2 z-10;
padding-left: 56px;
}

.mode-grid .data-list-bulk-actions {
@apply bg-white w-full pt-2 z-10 pl-2;
@apply bg-white w-full pt-2 z-10 pl-2 static;
}

.data-list-footer {
Expand Down
8 changes: 3 additions & 5 deletions resources/views/auth/passwords/reset.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

@section('content')

<h1 class="mb-3 pt-7 text-center text-grey-80">{{ __('Reset Password') }}</h1>
<h1 class="mb-3 pt-7 text-center text-grey-80">{{ $title }}</h1>

<div class="card auth-card mx-auto">

<form method="POST" action="{{ route('statamic.password.reset.action') }}">
<form method="POST" action="{{ $action }}">
@csrf

<input type="hidden" name="token" value="{{ $token }}">
Expand Down Expand Up @@ -42,9 +42,7 @@
<input id="password-confirm" type="password" class="input-text input-text" name="password_confirmation" required>
</div>

<button type="submit" class="btn-primary">
{{ __('Reset Password') }}
</button>
<button type="submit" class="btn-primary">{{ $title }}</button>

</form>

Expand Down
5 changes: 4 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
});

Route::group(['prefix' => config('statamic.routes.action')], function () {
Route::post('forms', 'FormController@store')->name('forms.store');
Route::post('forms/{form}', 'FormController@submit')->name('forms.submit');

Route::get('protect/password', '\Statamic\Auth\Protect\Protectors\Password\Controller@show')->name('protect.password.show');
Route::post('protect/password', '\Statamic\Auth\Protect\Protectors\Password\Controller@store')->name('protect.password.store');
Expand All @@ -29,6 +29,9 @@
Route::post('password/email', 'ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'ResetPasswordController@reset')->name('password.reset.action');

Route::get('activate/{token}', 'ActivateAccountController@showResetForm')->name('account.activate');
Route::post('activate', 'ActivateAccountController@reset')->name('account.activate.action');
});

Statamic::additionalActionRoutes();
Expand Down
6 changes: 5 additions & 1 deletion src/Actions/SendPasswordReset.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public function buttonText()

public function run($users, $values)
{
$users->each->generateTokenAndSendPasswordResetNotification();
$users->each(function ($user) {
$user->password()
? $user->generateTokenAndSendPasswordResetNotification()
: $user->generateTokenAndSendActivateAccountNotification();
});
}
}
1 change: 1 addition & 0 deletions src/Auth/Passwords/PasswordBrokerManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected function createTokenRepository(array $config)
return new TokenRepository(
$this->app['files'],
$this->app['hash'],
$config['table'],
$key,
$config['expire'],
$config['throttle'] ?? 0
Expand Down
11 changes: 9 additions & 2 deletions src/Auth/Passwords/PasswordReset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@

class PasswordReset
{
const BROKER_RESETS = 'resets';
const BROKER_ACTIVATIONS = 'activations';

protected static $url;
protected static $redirect;

public static function url($token)
public static function url($token, $broker)
{
$route = $broker === self::BROKER_ACTIVATIONS ? 'statamic.account.activate' : 'statamic.password.reset';

$defaultUrl = route($route, $token);

$url = static::$url
? sprintf('%s?token=%s', static::$url, $token)
: route('statamic.password.reset', $token);
: $defaultUrl;

parse_str(parse_url($url, PHP_URL_QUERY) ?: '', $query);

Expand Down
8 changes: 6 additions & 2 deletions src/Auth/Passwords/TokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class TokenRepository extends DatabaseTokenRepository
protected $expires;
protected $path;

public function __construct(Filesystem $files, HasherContract $hasher, $hashKey, $expires = 60, $throttle = 60)
public function __construct(Filesystem $files, HasherContract $hasher, $table, $hashKey, $expires = 60, $throttle = 60)
{
$this->files = $files;
$this->hasher = $hasher;
$this->hashKey = $hashKey;
$this->expires = $expires * 60;
$this->throttle = $throttle;

$this->path = storage_path('statamic/password_resets.yaml');
$this->path = storage_path("statamic/password_resets/$table.yaml");
}

public function create(CanResetPasswordContract $user)
Expand Down Expand Up @@ -92,6 +92,10 @@ protected function getResets()

protected function putResets($resets)
{
if (! $this->files->isDirectory($dir = dirname($this->path))) {
$this->files->makeDirectory($dir);
}

$this->files->put($this->path, YAML::dump($resets->all()));
}
}
27 changes: 19 additions & 8 deletions src/Auth/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Statamic\Notifications\ActivateAccount as ActivateAccountNotification;
use Statamic\Notifications\PasswordReset as PasswordResetNotification;
use Statamic\Statamic;
use Statamic\Support\Str;

abstract class User implements
UserContract,
Expand Down Expand Up @@ -55,7 +56,7 @@ public function initials()
{
$surname = '';
if ($name = $this->get('name')) {
if (str_contains($name, ' ')) {
if (Str::contains($name, ' ')) {
[$name, $surname] = explode(' ', $name);
}
} else {
Expand Down Expand Up @@ -182,26 +183,36 @@ public function routeNotificationForMail($notification = null)

public function sendPasswordResetNotification($token)
{
$notification = $this->password()
? new PasswordResetNotification($token)
: new ActivateAccountNotification($token);
$this->notify(new PasswordResetNotification($token));
}

$this->notify($notification);
public function sendActivateAccountNotification($token)
{
$this->notify(new ActivateAccountNotification($token));
}

public function generateTokenAndSendPasswordResetNotification()
{
$this->sendPasswordResetNotification($this->generatePasswordResetToken());
}

public function getPasswordResetUrl()
public function generateTokenAndSendActivateAccountNotification()
{
return PasswordReset::url($this->generatePasswordResetToken());
$this->sendActivateAccountNotification($this->generateActivateAccountToken());
}

public function generatePasswordResetToken()
{
return Password::broker()->createToken($this);
$broker = config('statamic.users.passwords.'.PasswordReset::BROKER_RESETS);

return Password::broker($broker)->createToken($this);
}

public function generateActivateAccountToken()
{
$broker = config('statamic.users.passwords.'.PasswordReset::BROKER_ACTIVATIONS);

return Password::broker($broker)->createToken($this);
}

public static function __callStatic($method, $parameters)
Expand Down
Loading

0 comments on commit 33c736f

Please sign in to comment.