/plushcap/analysis/twilio/authenticate-yii2-users-twilio-verify

Authenticate Yii2 Users Using Twilio Verify

What's this blog post about?

A user's phone number can be verified using Twilio Verify API, which guarantees that the database only contains users with verified phone numbers. The application will support the ability to register users and allow them to login and view a simplistic user dashboard. During registration, a unique code will be sent to the user's phone, which they will need to use for verification purposes. Once verified, user details will be moved to the main user table in the database. To verify that the application was created successfully, navigate into the yii-verify folder and run the application. The application will be served on localhost on port 8080. Open the site in your browser (http://localhost:8080) where you should see the welcome page. Configure the database connection by opening config/db.php and updating its content. Create migrations for the two database tables that the application will use, user and temporary_user. Modify the default content in the migration files generated above, starting with migrations/m<YYMMDD_HHMMSS>_create_user_table.php. Edit the migration files to create the two tables. Create an Active Record class which can also be considered as a model for the temporary_user table. Create a new form to represent the data requested from the user during the sign up stage. To verify that the application was created successfully, navigate into the yii-verify folder and run the application. The application will be served on localhost on port 8080. Open the site in your browser (http://localhost:8080) where you should see the welcome page. Configure the database connection by opening config/db.php and updating its content. Create migrations for the two database tables that the application will use, user and temporary_user. Modify the default content in the migration files generated above, starting with migrations/m<YYMMDD_HHMMSS>_create_user_table.php. Edit the migration files to create the two tables. Create an Active Record class which can also be considered as a model for the temporary_user table. Create a new form to represent the data requested from the user during the sign up stage. To verify that the application was created successfully, navigate into the yii-verify folder and run the application. The application will be served on localhost on port 8080. Open the site in your browser (http://localhost:8080) where you should see the welcome page. Configure the database connection by opening config/db.php and updating its content. Create a service that allows us to handle SMS verification by using the Twilio Verify API. Create an action in controllers/SiteController.php, named actionVerifyUser, to utilize the newly created form. Modify the main application layout view to display the flash message added to the session whenever a user is verified. Finally, modify the login view to display the flash message added to the session whenever a user is verified. The application will allow users to register and be verified before they can access their details.

Company
Twilio

Date published
May 12, 2021

Author(s)
Oluyemi Olususi

Word count
3747

Language
English

Hacker News points
None found.


By Matt Makai. 2021-2024.