This module allows users to log in using field data values, administrators can customize the fields allowed to log in.
Special fields can use plug-ins or hooks to query the user UID to achieve login, for example: Phone number (field). You can also use any data to log in,
you only need to query and output the user's UID.

Project link

https://www.drupal.org/project/field_login

Comments

qiutuo created an issue. See original summary.

vishal.kadam’s picture

Thank you for applying!

Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.

The important notes are the following.

  • If you have not done it yet, you should run phpcs --standard=Drupal,DrupalPractice on the project, which alone fixes most of what reviewers would report.
  • For the time this application is open, only your commits are allowed.
  • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status won't be changed by this application and no other user will be able to opt projects into security advisory policy.
  • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

To the reviewers

Please read How to review security advisory coverage applications, Application workflow, What to cover in an application review, and Tools to use for reviews.

The important notes are the following.

  • It is preferable to wait for a Code Review Administrator before commenting on newly created applications. Code Review Administrators will do some preliminary checks that are necessary before any change on the project files is suggested.
  • Reviewers should show the output of a CLI tool only once per application.
  • It may be best to have the applicant fix things before further review.

For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues.

vishal.kadam’s picture

Title: [2.0.x] User Field Login » [2.x] User Field Login
Issue summary: View changes
Rushikesh Raval’s picture

Status: Needs review » Needs work

Solve phpcs Error

phpcs --standard=Drupal,DrupalPractice web/modules/contrib/field_login/

FILE: web/modules/contrib/field_login/src/Form/FieldLoginSettingsForm.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
74 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------

FILE: .../drupal104/web/modules/contrib/field_login/src/FieldLoginPluginManager.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------
47 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
48 | WARNING | Unused variable $plugin_id.
64 | ERROR | Missing parameter comment
--------------------------------------------------------------------------------

FILE: web/modules/contrib/field_login/src/FieldLoginPluginManagerInterface.php
--------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
--------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found
| | "\r\n"
7 | ERROR | [x] Missing interface doc comment
9 | ERROR | [x] Missing function doc comment
11 | ERROR | [x] Missing function doc comment
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: web/modules/contrib/field_login/src/UserAuthDecorator.php
--------------------------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 4 LINES
--------------------------------------------------------------------------------
8 | ERROR | [x] Use statements should be sorted alphabetically. The first
| | wrong one is
| | Drupal\Core\DependencyInjection\DependencySerializationTrait.
55 | ERROR | [ ] Parameter $flood is not described in comment
55 | ERROR | [ ] Parameter $config_factory is not described in comment
63 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 4
| | spaces
107 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: web/modules/contrib/field_login/src/UserVerificationInterface.php
--------------------------------------------------------------------------------
FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
--------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found
| | "\r\n"
5 | WARNING | [x] Unused use statement
9 | WARNING | [ ] The class short comment should describe what the class does
| | and not simply repeat the class name
15 | ERROR | [ ] Missing parameter comment
17 | ERROR | [x] Additional blank lines found at end of doc comment
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: web/modules/contrib/field_login/src/UserVerification.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
50 | ERROR | [x] Parameter comment must end with a full stop
52 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 4
| | spaces
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: web/modules/contrib/field_login/field_login.api.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
13 | ERROR | Missing parameter type
--------------------------------------------------------------------------------

Time: 420ms; Memory: 10MB

qiutuo’s picture

Hello, the above problem has been fixed, and there is no other prompt to execute phpcs.

vishal.kadam’s picture

1. FILE: field_login.info.yml

project: 'field_login'

Remove "project" from the info file, it will be added by drupal.org packaging automatically

2. FILE: field_login.module

  $form['name']['#title'] = t($settings->get('login_username_title'));
  $form['name']['#description'] = t($settings->get('login_username_description'));

Only string literals should be passed to t()

3. FILE: src/UserVerification.php

  public function __construct(
    EntityTypeManagerInterface $entity_type_manager,
    ModuleHandlerInterface $module_handler,
    FieldLoginPluginManagerInterface $field_login_plugin_manager,
    ConfigFactoryInterface $config_factory
  ) {

FILE: src/UserAuthDecorator.php

  public function __construct(
    UserAuthInterface $user_auth,
    UserVerificationInterface $user_verification,
    FloodInterface $flood,
    ConfigFactoryInterface $config_factory,
    MessengerInterface $messenger,
    RequestStack $request_stack
  ) {

Function and method declarations are written on a single line.

4. FILE: src/Form/FieldLoginSettingsForm.php

  /**
   * AdminToolbarToolsSettingsForm constructor.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
   *   The factory for configuration objects.
   * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
   *   The entity field manager.
   */
  public function __construct(ConfigFactoryInterface $configFactory, EntityFieldManagerInterface $entity_field_manager) {

The documentation comment for constructors is not mandatory anymore, If it is given, the description must be Constructs a new [class name] object. where [class name] includes the class namespace.

qiutuo’s picture

Hello, I have corrected the above issue.

vishal.kadam’s picture

If you changed what has been reported, please change the status to Needs review. In this way, reviewers will know everything has been changed and can be reviewed again.

qiutuo’s picture

Status: Needs work » Needs review
apaderno’s picture

Status: Needs review » Needs work

I do not have time for a deeper review. I just wanted to report this.

    $username_label = $settings->get('login_username_title');
    $description = $settings->get('login_username_description');

    // Check for settings to enable login by field.
    if ($settings->get('override_login_labels')) {
      $form['name']['#title'] = t('@label', ['@label' => $username_label]);
      $form['name']['#description'] = t('@description', ['@description' => $description]);
    }

$form['name']['#title'] = t('@label', ['@label' => $username_label]); does not do any translation and it is exactly as using $form['name']['#title'] = $username_label;
Configuration objects are translatable, but translating them does not involve calling t(). There is documentation about translating configuration objects; I will report here the documentation link when I find it.

apaderno’s picture