Upgrade to rc5
This commit is contained in:
@@ -48,7 +48,7 @@ return [
|
||||
return $file->next();
|
||||
},
|
||||
'nextWithTemplate' => function (File $file) {
|
||||
$files = $file->templateSiblings()->sortBy('sort', 'asc', 'filename', 'asc');
|
||||
$files = $file->templateSiblings()->sort('sort', 'asc', 'filename', 'asc');
|
||||
$index = $files->indexOf($file);
|
||||
|
||||
return $files->nth($index + 1);
|
||||
@@ -72,7 +72,7 @@ return [
|
||||
return $file->prev();
|
||||
},
|
||||
'prevWithTemplate' => function (File $file) {
|
||||
$files = $file->templateSiblings()->sortBy('sort', 'asc', 'filename', 'asc');
|
||||
$files = $file->templateSiblings()->sort('sort', 'asc', 'filename', 'asc');
|
||||
$index = $files->indexOf($file);
|
||||
|
||||
return $files->nth($index - 1);
|
||||
|
@@ -27,7 +27,7 @@ return [
|
||||
return $page->errors();
|
||||
},
|
||||
'files' => function (Page $page) {
|
||||
return $page->files()->sortBy('sort', 'asc', 'filename', 'asc');
|
||||
return $page->files()->sort('sort', 'asc', 'filename', 'asc');
|
||||
},
|
||||
'hasChildren' => function (Page $page) {
|
||||
return $page->hasChildren();
|
||||
@@ -47,9 +47,9 @@ return [
|
||||
'next' => function (Page $page) {
|
||||
return $page
|
||||
->nextAll()
|
||||
->filterBy('intendedTemplate', $page->intendedTemplate())
|
||||
->filterBy('status', $page->status())
|
||||
->filterBy('isReadable', true)
|
||||
->filter('intendedTemplate', $page->intendedTemplate())
|
||||
->filter('status', $page->status())
|
||||
->filter('isReadable', true)
|
||||
->first();
|
||||
},
|
||||
'num' => function (Page $page) {
|
||||
@@ -73,9 +73,9 @@ return [
|
||||
'prev' => function (Page $page) {
|
||||
return $page
|
||||
->prevAll()
|
||||
->filterBy('intendedTemplate', $page->intendedTemplate())
|
||||
->filterBy('status', $page->status())
|
||||
->filterBy('isReadable', true)
|
||||
->filter('intendedTemplate', $page->intendedTemplate())
|
||||
->filter('status', $page->status())
|
||||
->filter('isReadable', true)
|
||||
->last();
|
||||
},
|
||||
'previewUrl' => function (Page $page) {
|
||||
|
@@ -24,7 +24,7 @@ return [
|
||||
return $site->drafts();
|
||||
},
|
||||
'files' => function (Site $site) {
|
||||
return $site->files()->sortBy('sort', 'asc', 'filename', 'asc');
|
||||
return $site->files()->sort('sort', 'asc', 'filename', 'asc');
|
||||
},
|
||||
'options' => function (Site $site) {
|
||||
return $site->permissions()->toArray();
|
||||
|
@@ -35,6 +35,21 @@ return [
|
||||
'license' => function (System $system) {
|
||||
return $system->license();
|
||||
},
|
||||
'loginMethods' => function (System $system) {
|
||||
return array_keys($system->loginMethods());
|
||||
},
|
||||
'pendingChallenge' => function () {
|
||||
if ($this->session()->get('kirby.challenge.email') === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// fake the email challenge if no challenge was created
|
||||
// to avoid leaking whether the user exists
|
||||
return $this->session()->get('kirby.challenge.type', 'email');
|
||||
},
|
||||
'pendingEmail' => function () {
|
||||
return $this->session()->get('kirby.challenge.email');
|
||||
},
|
||||
'requirements' => function (System $system) {
|
||||
return $system->toArray();
|
||||
},
|
||||
@@ -86,6 +101,9 @@ return [
|
||||
'isOk',
|
||||
'isInstallable',
|
||||
'isInstalled',
|
||||
'loginMethods',
|
||||
'pendingChallenge',
|
||||
'pendingEmail',
|
||||
'title',
|
||||
'translation'
|
||||
],
|
||||
|
@@ -24,7 +24,7 @@ return [
|
||||
return $user->email();
|
||||
},
|
||||
'files' => function (User $user) {
|
||||
return $user->files()->sortBy('sort', 'asc', 'filename', 'asc');
|
||||
return $user->files()->sort('sort', 'asc', 'filename', 'asc');
|
||||
},
|
||||
'id' => function (User $user) {
|
||||
return $user->id();
|
||||
|
@@ -19,7 +19,7 @@ return [
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/login',
|
||||
'pattern' => 'auth/code',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
@@ -30,11 +30,7 @@ return [
|
||||
throw new InvalidArgumentException('Invalid CSRF token');
|
||||
}
|
||||
|
||||
$email = $this->requestBody('email');
|
||||
$long = $this->requestBody('long');
|
||||
$password = $this->requestBody('password');
|
||||
|
||||
$user = $this->kirby()->auth()->login($email, $password, $long);
|
||||
$user = $auth->verifyChallenge($this->requestBody('code'));
|
||||
|
||||
return [
|
||||
'code' => 200,
|
||||
@@ -43,6 +39,65 @@ return [
|
||||
];
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/login',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$auth = $this->kirby()->auth();
|
||||
$methods = $this->kirby()->system()->loginMethods();
|
||||
|
||||
// csrf token check
|
||||
if ($auth->type() === 'session' && $auth->csrf() === false) {
|
||||
throw new InvalidArgumentException('Invalid CSRF token');
|
||||
}
|
||||
|
||||
$email = $this->requestBody('email');
|
||||
$long = $this->requestBody('long');
|
||||
$password = $this->requestBody('password');
|
||||
|
||||
if ($password) {
|
||||
if (isset($methods['password']) !== true) {
|
||||
throw new InvalidArgumentException('Login with password is not enabled');
|
||||
}
|
||||
|
||||
if (
|
||||
isset($methods['password']['2fa']) === true &&
|
||||
$methods['password']['2fa'] === true
|
||||
) {
|
||||
$challenge = $auth->login2fa($email, $password, $long);
|
||||
} else {
|
||||
$user = $auth->login($email, $password, $long);
|
||||
}
|
||||
} else {
|
||||
if (isset($methods['code']) === true) {
|
||||
$mode = 'login';
|
||||
} elseif (isset($methods['password-reset']) === true) {
|
||||
$mode = 'password-reset';
|
||||
} else {
|
||||
throw new InvalidArgumentException('Login without password is not enabled');
|
||||
}
|
||||
|
||||
$challenge = $auth->createChallenge($email, $long, $mode);
|
||||
}
|
||||
|
||||
if (isset($user)) {
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
'user' => $this->resolve($user)->view('auth')->toArray()
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
|
||||
// don't leak users that don't exist at this point
|
||||
'challenge' => $challenge ?? 'email'
|
||||
];
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/logout',
|
||||
'method' => 'POST',
|
||||
|
@@ -27,7 +27,7 @@ return [
|
||||
'pattern' => '(:all)/files',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $path) {
|
||||
return $this->parent($path)->files()->sortBy('sort', 'asc', 'filename', 'asc');
|
||||
return $this->parent($path)->files()->sort('sort', 'asc', 'filename', 'asc');
|
||||
}
|
||||
],
|
||||
[
|
||||
@@ -110,7 +110,7 @@ return [
|
||||
$files = $this
|
||||
->site()
|
||||
->index(true)
|
||||
->filterBy('isReadable', true)
|
||||
->filter('isReadable', true)
|
||||
->files();
|
||||
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
|
@@ -78,7 +78,7 @@ return [
|
||||
$pages = $this
|
||||
->site()
|
||||
->index(true)
|
||||
->filterBy('isReadable', true);
|
||||
->filter('isReadable', true);
|
||||
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $pages->search($this->requestQuery('q'));
|
||||
|
@@ -11,7 +11,7 @@ return [
|
||||
'pattern' => 'users',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->users();
|
||||
return $this->users()->sort('username', 'asc', 'email', 'asc');
|
||||
}
|
||||
],
|
||||
[
|
||||
|
Reference in New Issue
Block a user