Jump to content

Email login


jquestion
 Share

Recommended Posts

Hi,

I've just set up a client area with ProcessWire based on Ryans step by step guide here -

It's pretty much identical, client areas are rendered depending on the users name.

This means I can only have one login per client since users names must be unqiue. Often there's time where I have multiple contacts for one client and ideally I'd like to create a user login for each person involved.

One login per client works, but ideally I'd like a unique login based on their email address.

Is there a way to allow users to login using their email address and using a users name more than once?

No worries if this isn't acheivable, I'm extremely happy with PW and have been very impressed at how easy it is to use. To all those involved, great work!

Cheers

Link to comment
Share on other sites

Jquestion, one good thing that has changed in ProcessWire since that post you linked to was written is that the user system is now built around pages and templates. You can add whatever fields you want to your 'user' template. This opens up a lot more possibilities that didn't exist back when that post was written. So if you want multiple users to have access to a given page, you might just want to create and add a new page reference field to the 'user' template. You might call it something like "client_page". Use 'PageListSelect' or 'PageListSelectMultiple' as the Input field type for that page field. Now when you edit a user, you can select what private page(s) they should be able to view. In your template used by that private page, you'll want to have some kind of access check in there like this:

if($user->isGuest() || $user->client_page->id != $page->id) 
   throw new WirePermissionException("You don't have access to this page"); 

or if a multi-page reference field:

if($user->isGuest() || !$user->client_pages->has($page))

   throw new WirePermissionException("You don't have access to this page"); 

To allow for logins by email address:

if($input->post->login_submit && $input->post->email) {
   $email = $sanitizer->email($input->post->email); 
   $emailUser = $users->get("email=$email"); 
   if($emailUser->id) {
       $user = $session->login($emailUser->name, $input->post->pass); 
       if($user) {
           echo "Login success!";
       } else {
           echo "Login failed!";
       }
   } else {
       echo "Unrecognized email address";
   }
}
  • Like 4
Link to comment
Share on other sites

  • 2 years later...

Hi there,

i´ve got a strange problem with my email-login script.

Some email-addresses will work, some won´t.

That means, the web.de / gmx.de or t-online.de mail-addresses failed during the login-process ( Email unknown ).

The test@myname.de email-addresses are working.

Do you guys have some ideas how to fix that?

Greetz

Bernd

Link to comment
Share on other sites

Do you have any more information on this problem? Can you show the code? Is there anything in the logs?

Btw the German keyboard has a key for the straight apostrophe, should be next to Ä (Shift+#). You’re using an acute accent which puts weird gaps into words. You should also use that apostrophe to delimit static strings in PHP.

Link to comment
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
 Share

×
×
  • Create New...