mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-06 10:16:37 +02:00
Feature: Ability to Login with Email
Thanks to @gsumpster for https://github.com/getgrav/grav-plugin-admin/pull/685 * implemented email-login, close #674 * changed placeholder text * Fix Utils namespace thing * Drop use * Cleanup styling
This commit is contained in:
@@ -14,6 +14,7 @@ use Grav\Common\Themes;
|
||||
use Grav\Common\Uri;
|
||||
use Grav\Common\User\User;
|
||||
use Grav\Common\Utils;
|
||||
use Grav\Plugin\Admin\Utils as AdminUtils;
|
||||
use RocketTheme\Toolbox\File\File;
|
||||
use RocketTheme\Toolbox\File\JsonFile;
|
||||
use RocketTheme\Toolbox\ResourceLocator\UniformResourceIterator;
|
||||
@@ -105,6 +106,9 @@ class Admin
|
||||
$this->user = $this->grav['user'];
|
||||
$this->permissions = [];
|
||||
$language = $this->grav['language'];
|
||||
|
||||
// Load utility class
|
||||
require_once __DIR__ . '/utils.php';
|
||||
|
||||
if ($language->enabled()) {
|
||||
$this->multilang = true;
|
||||
@@ -175,7 +179,12 @@ class Admin
|
||||
public function authenticate($data, $post)
|
||||
{
|
||||
if (!$this->user->authenticated && isset($data['username']) && isset($data['password'])) {
|
||||
$user = User::load($data['username']);
|
||||
// Perform RegEX check on submitted username to check for emails
|
||||
if (filter_var($data['username'], FILTER_VALIDATE_EMAIL)) {
|
||||
$user = AdminUtils::findUserbyEmail($data['username']);
|
||||
} else {
|
||||
$user = User::load($data['username']);
|
||||
}
|
||||
|
||||
//default to english if language not set
|
||||
if (empty($user->language)) {
|
||||
|
||||
Reference in New Issue
Block a user