benbyf

session->login($u,$p); what can the $u be?

11 posts in this topic

quick question, can the $username in login() be email OR username, or anything else?

Share this post


Link to post
Share on other sites
6 minutes ago, benbyf said:

quick question, can the $username in login() be email OR username, or anything else?

Two options:

https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/?page=4#comment-89599

https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/?page=4#comment-89616

You should read about the pros and cons of each.

1 person likes this

Share this post


Link to post
Share on other sites

Great options @adrian.

Strangely, I only asked as when login in with login() on my site it already allows either, which i thought was strange.

Share this post


Link to post
Share on other sites
2 hours ago, benbyf said:

Strangely, I only asked as when login in with login() on my site it already allows either, which i thought was strange.

Something sounds wrong there - are you sure you don't have something else that is handling the email to username check? I don't see anything in the login method to handle an email: https://github.com/processwire/processwire/blob/35df716082b779de0e53a3fcf7996403c49c9f8a/wire/core/Session.php#L704 and it doesn't work for me.

Share this post


Link to post
Share on other sites

@adrian Could it be that if the name and email are the same but the sanitizer is changing @ to - and thus making them equivalent?

Share this post


Link to post
Share on other sites

If you used the email for the name it does indeed work.

1 person likes this

Share this post


Link to post
Share on other sites

@adrian so i'm right in saying if the name is stored as e.g. yourname-web.com

then both yourname-web.com and yourname@web.com log me in.

Share this post


Link to post
Share on other sites
1 minute ago, benbyf said:

@adrian so i'm right in saying if the name is stored as e.g. yourname-web.com

then both yourname-web.com and yourname@web.com log me in.

That makes sense for sure. When I sent you those other links, I assumed that the usernames would be different to the email address.

1 person likes this

Share this post


Link to post
Share on other sites

ok, well something to bare in mind and maybe something that needs remedying or not. @ryan?

Share this post


Link to post
Share on other sites
On 1/13/2017 at 2:42 PM, benbyf said:

ok, well something to bare in mind and maybe something that needs remedying or not. @ryan?

Would be nice to know, if you can use this as a feature :-) It would make a custom front-end login with email easier (if you make sure email-address updates are reflected to the username as well).

1 person likes this

Share this post


Link to post
Share on other sites

using both at the moment to login, email and username created by PW out of the email.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By dweeda
      In a PW file, I successfully login a $user using $session->login().
      I later redirect to a different PHP file. It's not a PW template file so I do the appropriate  include("/path/to/processwire/index.php");
      But then I try to get the logged in $user->name and it always gives me 'guest'.  And if I set a $session value at login, in the redirected file my values are lost.
      I am new to PW so I am surprised.  What am I missing?
      Thx
    • By fbg13
      When echoing a date field directly from the $user variable
      echo $user->date;  the timestamp is printed. Using
      echo $users->get($user->id)->date; prints the correct formated value.
      Is this a bug or or intended?
    • By beto
      I can't add a new value to a custom PageArray field  for my user.
       
      However, when I create a new user, I CAN add the new PageArray value:
       
      I need help. Thank you very much.
       
    • By gebeer
      Hello,
      I have a Process module with a user dashboard and I would like to have the user page edit screen at a custom URL 'myprofile'.
      I cannot use the default profile edit page because it does not support tabbed interfaces.
      The method for executing the user edit page from within my module looks like this
      public function ___executeMyprofile() { $processUser = $this->modules->get('ProcessUser'); return $processUser->executeEdit(); } The user edit screen displays when I go to /dashboard/myprofile. But the request is redirected several times and I end up at the URL /access/users/edit/?id=5522 which I wanted to avoid.
      This happens because of this line in ProcessPageEdit.module.
      I guess the solution lies in hooking into the ___loadPage() method from within my Process module. But, honestly, I have no clue on how to put the pieces together.
      So I need some pointers on how to best achieve the goal of having the current user's edit page under a custom URL in the admin area, ideally in the scenario of a custom Process module.
      Any help would be much appreciated.
      EDIT:
      I tried some variations of hooking like
      public function ___executeMyprofile() { $this->addHookBefore("ProcessPageEdit::loadPage", $this, "interceptRedirect"); $processUser = $this->modules->get('ProcessUser'); return $processUser->executeEdit(); } protected function interceptRedirect(HookEvent $event) { $event->replace = true; $event->return = $this->user; } but the hook is not being executed at all. Also when placing the call to the hook in my Process module's init() method. Also when using an After hook and not replacing the hooked method. No luck so far...
    • By Mustafa Online
      Hello PW Lovers! i know that i can edit user template (Profile) and add as many fields as i want,
      But i wanna know if i can create pages and associate them to users, For Example: what if i have a users system & each
      user has a profile + custom page with personal info, and any user could edit his own page - Thanx