Use ONLY email as the login

Discussion in 'aMember Pro v.4' started by tunahead, Apr 7, 2012.

  1. tunahead

    tunahead New Member

    Joined:
    Mar 31, 2012
    Messages:
    4
    Is there an option to allow only the email address to be used as the login, and not the username? If not, where would I need to edit the code to account for this?

    Thanks in advance!
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Why you need this? You can configure aMember so user will not even know he have username. Also modify strings at /amember/admin-trans-global and remove any references to username. Username will be accepted still but user will not know that he have username.
  3. tunahead

    tunahead New Member

    Joined:
    Mar 31, 2012
    Messages:
    4
    Thanks for the reply, I actually want them to still have a username, I just don't want that username to be used for the login. The reason for this is because on my site, users will be able to view other usernames to interact with them. So since those names will be out there and visible, I would rather not have them be used as the login as then potential hackers already have half of what they need to login.

    So is there a way to disable having the username be accepted as the login, and use only their email address?
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Well there is no easy way to disable this.
    This is possible but require aMember core files modification, so your changes will be lost on upgrade.
  5. tunahead

    tunahead New Member

    Joined:
    Mar 31, 2012
    Messages:
    4
    Can you point me in the right direction, I can take a look and see if I can modify it. Just need to know where to start looking.

    Thanks
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Check /amember/application/default/models/User.php
    function getAuthenticatedRow
    Just test $login variable and return Am_Auth_Result::INVALID_INPUT if it is not email address.
  7. wallpaper_01

    wallpaper_01 Member

    Joined:
    Mar 9, 2011
    Messages:
    116
  8. tunahead

    tunahead New Member

    Joined:
    Mar 31, 2012
    Messages:
    4
    Thanks Alexander,

    I ended up just removing the line

    "else
    return $this->findFirstByLogin($login);"

    from

    "function getByLoginOrEmail($login){
    if (!strlen($login))
    return null;
    if (strpos($login, '@')!==false)
    return $this->findFirstByEmail($login);
    else
    return $this->findFirstByLogin($login);
    }"

    And then reworded the login page to just read email address and removed the username wording.

Share This Page