This commit is contained in:
Bastian Allgeier
2019-01-15 11:43:30 +01:00
parent 8070893b64
commit f596ff5c4c
5 changed files with 46 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "getkirby/cms",
"description": "The Kirby 3 core",
"version": "3.0.0-RC-6.0",
"version": "3.0.0",
"license": "proprietary",
"keywords": ["kirby", "cms", "core"],
"homepage": "https://getkirby.com",

2
kirby/composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "795a9baff274c8a85cd3670e696e6331",
"content-hash": "fccb729b1a9f9683c43cc376216e49cf",
"packages": [
{
"name": "claviska/simpleimage",

View File

@@ -35,12 +35,16 @@ return [
$long = $this->requestBody('long');
$password = $this->requestBody('password');
if ($user = $this->kirby()->auth()->login($email, $password, $long)) {
return [
'code' => 200,
'status' => 'ok',
'user' => $this->resolve($user)->view('auth')->toArray()
];
try {
if ($user = $this->kirby()->auth()->login($email, $password, $long)) {
return [
'code' => 200,
'status' => 'ok',
'user' => $this->resolve($user)->view('auth')->toArray()
];
}
} catch (Throwable $e) {
// catch any kind of login error
}
throw new InvalidArgumentException('Invalid email or password');

View File

@@ -97,7 +97,13 @@ function css($url, $options = null)
$url = $component($kirby, $url, $options);
}
$url = $url === '@auto' ? Url::toTemplateAsset('css/templates', 'css') : Url::to($url);
if ($url === '@auto') {
if (!$url = Url::toTemplateAsset('css/templates', 'css')) {
return null;
}
}
$url = Url::to($url);
$attr = array_merge((array)$options, [
'href' => $url,
'rel' => 'stylesheet'
@@ -345,7 +351,13 @@ function js($url, $options = null)
$url = $component($kirby, $url, $options);
}
$url = $url === '@auto' ? Url::toTemplateAsset('js/templates', 'js') : Url::to($url);
if ($url === '@auto') {
if (!$url = Url::toTemplateAsset('js/templates', 'js')) {
return null;
}
}
$url = Url::to($url);
$attr = array_merge((array)$options, ['src' => $url]);
return '<script ' . attr($attr) . '></script>';

View File

@@ -42,4 +42,24 @@ class Url extends BaseUrl
return file_exists($file) === true ? $url : null;
}
/**
* Smart resolver for internal and external urls
*
* @param string $path
* @param array $options
* @return string
*/
public static function to(string $path = null, array $options = null): string
{
$kirby = App::instance();
if ($handler = $kirby->component('url')) {
return $handler($kirby, $path, $options, function (string $path = null, array $options = null) {
return parent::to($path, $options);
});
}
return parent::to($path, $options);
}
}