Welcome Guest, Not a member yet? Register   Sign In
Shield: validFields includes username but does not pass validation
#1

Hi all,

currently I am migrating from Myth\Auth to Shield and have issues to allow username additional to mail as login credential. Auth.php:

PHP Code:
public array $validFields = [
        'email',
        'username',
    ]; 

I reworked the login view so that it acts like Myth\Auth and the browsers allows to post plain usernames instead mail addresses. login.php:

PHP Code:
<?php if (config('Auth')->validFields === ['email']): ?>
  <input type="email" class="w3-input" name="email" inputmode="email" autocomplete="email" placeholder="<?= lang('Auth.email'?>" value="<?= old('email'?>" required />
<?php else: ?>
  <input type="text" class="w3-input" name="email" inputmode="email" autocomplete="email" placeholder="<?= lang('Auth.emailOrUsername'?>" value="<?= old('email'?>" required />
<?php endif ?>

When submitting form, I get mail field is not valid mail address. Any hints how to get both (email or username) working? When I rename the input to 'name=username', I get that email is required. Where did I miss to activate passing verification for additional username?

Is Shield ready for production or still beta? Thanks for your help.

Kimotu
Reply
#2

Hi,

Login username see:

https://github.com/codeigniter4/shield/discussions/323

Is Shield ready for production or still beta?

https://forum.codeigniter.com/showthread...#pid401007
Reply
#3

(11-03-2022, 03:06 PM)datamweb Wrote: Hi,

Login username see:

https://github.com/codeigniter4/shield/discussions/323

Is Shield ready for production or still beta?

https://forum.codeigniter.com/showthread...#pid401007

Ok, so it is an exclusive or and not just an or so that I can use both values (mail or username) randomly. Well, since still beta, I will better stay with Myth\Auth. No rework of authentication tables necessary and the password change process is  already included Smile Just thought the rework for new app version would be a good time to switch to "buildin" authentication.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB