Custom Db Authentication: Stored procedure

To allow your users authenticate on Nearforums using your db, create a procedure that selects the userid, username and useremail columns of the user, using user name and password as filter.

SQL Server sample

CREATE PROCEDURE dbo.SP_Nearforums_AuthenticateUser_TSQL
(@UserName nvarchar(256), @Password nvarchar(256))
AS
SELECT Id AS UserId, Name AS UserName, Email AS UserEmail FROM MyUserTable WHERE Name = @UserName AND Pass = @Password
GO

MySql sample

DELIMITER //
CREATE PROCEDURE sp_nearforums_authenticateuser_mysql(param_username nvarchar(256), param_password nvarchar(256))
BEGIN
SELECT id AS userid, name AS username, email AS useremail FROM my_user_table WHERE name = param_username AND Pass = param_password;
END //
DELIMITER ;

Last edited Jan 29, 2012 at 10:51 AM by jorgebg, version 2

Comments

No comments yet.