1.1.0 • Published 10 years ago

codeauth v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
10 years ago

CodeAuth


CodeAuth is a simple Node.js package that makes it easy to implement a confirmation code system to a project.

It's easy to get started, all CodeAuth needs is a MySQL database.

Create a simple project

var auth = require('codeauth');

auth.mysql({ // Create MySQL connection
	host: "localhost",
	user: "root",
	password: "mysql",
	database: "codeauth",
	table: "codes"
}, function() {
	callback(); // After connection is made + succesful
});

Generate a new code

function callback() {
	var userCode = new auth.code( "Test User", 6 ); // Generate new 6 digit long code for use only by user "Test User"
	userCode.store(); // Stores code hash in table
	somehowReplyBackToUser(userCode.code); // Send 6 digit code back to user to enter, could be a text message or email
}

Check if user entered a correct code

auth.check( "Test User", %code the user entered%, function( result ){ 
	if (result) somehowReplyBackToUser("Success!");
	else        somehowReplyBackToUser("Failure!");
	auth.close(); // Close MySQL Connection
});
1.1.0

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago