Skip to content

mcwebb/angular-twilio-verification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Angular Twilio Verification Module

Angular module for verifying phone numbers with Twilio's SMSs

Do phone number verification by sending an one-time code in an SMS via Twilio to user's phone. The verification code is stored locally, so this shouldn't be used where security is absolutely vital.

Installation

This module depends on Angular Twilio Module.

Install with Bower

# from the terminal at the root of your project
bower install angular-twilio-verification --save

Add to your module deps

angular.module('xxxx', ['mcwebb.twilio', 'mcwebb.twilio-verification'])

Example Use

Set up

angular.module('xxxx')
.config(function (TwilioVerificationProvider) {
	// the number Twilio number that SMSs should be sent from
	TwilioVerificationProvider.setFromNumber('+12402926537');
});

Use

angular.module('xxxx')
.controller('ExampleController', function ExampleController($scope, TwilioVerification) {
	$scope.submit = function (toNumber) {
		// toNumber formatted with international code e.g. '+12402926537'
		TwilioVerification.sendCode(toNumber)
		.then(function () {
			// SUCCESSFULY SENT - move to next step
		}, function (response) {
			// FAILED TO SEND - tell the user
		})
	};

	$scope.verify = function (verificationCode) {
		// returns boolean
		var verified = TwilioVerification.verifyCode(verificationCode);
		if (verified) {
			// ALL GOOD
		} else {
			// NOPE
		}
	}
});

About

Angular module for verifying phone numbers with Twilio's SMSs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published