USE [KO_MAIN]
GO
/****** Object: StoredProcedure [dbo].[ACCOUNT_LOGIN] Script Date: 08/11/2012 16:18:01 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ACCOUNT_LOGIN]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[ACCOUNT_LOGIN]
GO
USE [KO_MAIN]
GO
/****** Object: StoredProcedure [dbo].[ACCOUNT_LOGIN] Script Date: 08/11/2012 16:18:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Katana
-- Create date: 8/07/2012
-- Description: Account Login
-- =============================================
CREATE PROCEDURE [dbo].[ACCOUNT_LOGIN]
@AccountID varchar(21),
@Password varchar(32),
@nRet smallint OUTPUT
AS
SELECT @nRet = COUNT(strAccountID) FROM TB_USER WHERE strAccountID = @AccountID
IF @nRet = 0
BEGIN
INSERT INTO TB_USER (strAccountID, strPasswd) VALUES (@AccountID, @Password)
END
DECLARE @Password2 varchar(32), @Authority tinyint
SELECT @Password2 = strPasswd, @Authority = Authority FROM TB_USER WHERE strAccountID = @AccountID
IF @Authority = 255 -- Account is banned.
BEGIN
SET @nRet = 4
RETURN
END
ELSE IF @Password2 is NULL -- Password is empty.
BEGIN
SET @nRet = 3
RETURN
END
ELSE IF @Password2 <> @Password -- Invalid Password
BEGIN
SET @nRet = 3
RETURN
END
GO