Jump to content

Use of TfaTotp Module (2 Factor Authentication) in custom login-forms


Dennis Spohr
 Share

Recommended Posts

Hi all,

I have a custom login-page for my vistors and I want to implement a 2-factor authentication.

Looks like the TfaTotp-Module already has this functionality for the login-form of ProcessWire.
Can I use this module via the API for my custom login-form? How can I implement it?

I couldn't find any documentation.

Thanks,
Dennis

Link to comment
Share on other sites

The TfaTotp module is not a core module so it won't be covered in the core docs. The base Tfa class is in the API docs here: https://processwire.com/api/ref/tfa/

There's no tutorial AFAIK but you can refer to the implementation in ProcessLogin and there is a basic usage example given in the comments for Tfa.php:

 * USAGE
 * ~~~~~~
 * $tfa = new Tfa();
 * 
 * if($tfa->success()) {
 *   $session->redirect('after/login/url/');
 * 
 * } else if($tfa->active()) {
 *   echo $tfa->render();
 * 
 * } else if($input->post('submit_login')) {
 *   $name = $input->post('name');
 *   $pass = $input->post('pass');
 *   $tfa->start($name, $pass); 
 * 
 *   // the start() method performs a redirect if TFA is active for the user
 *   // place your regular code to login user here, which will be used if TFA is not active for the user
 * 
 * } else {
 *   // render login form
 * }

Also see the introductory blog post for info about how the TFA selection field is added to the user template: https://processwire.com/blog/posts/processwire-3.0.109-adds-two-factor-authentication/

  • Like 2
Link to comment
Share on other sites

Moderator note: this is not a support board for a new module, so I'm moving it to the General Support area of the forum.

The "Modules/Plugins" section of the forum is for dedicated module support threads. If you have a general question regarding ProcessWire or "how to do [x] with ProcessWire", you should post it to the General Support area – or if it's a question regarding an existing module, check the "Support Board" link from the modules directory entry for that module and post your question to the linked thread instead.

Thanks!

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...