Manaus Posted July 23 Posted July 23 Hello, does it exist a module for managing login and register pages? Or do I need to write the logic myself? Thank you very much
Jan Romero Posted July 23 Posted July 23 There's LoginRegisterPro: https://processwire.com/store/login-register-pro/ And the older, free LoginRegister: https://github.com/ryancramerdesign/LoginRegister You can also roll your own, a simple login handler might look like this: <?php namespace ProcessWire; http_response_code(400); header('content-type: text/plain'); $username = input()->post->selectorValue('username'); $potentialUsers = users()->find("roles=my-user, name|email={$username}"); if ($potentialUsers->count != 1) die('Uh-oh.'); try { if (!session()->login($potentialUsers->first(), input()->post->pass)) die("Username or password invalid."); } catch (SessionLoginThrottleException $e) { http_response_code(429); die($e->getMessage()); } http_response_code(200); header('HX-Redirect: '. pages()->request()->getRequestPath()); die('Hello.'); 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now