ALTER PROCEDURE [dbo].[MAIN_LOGIN]
@AccountID char(21),
@Password char(21),
@nRet smallint OUTPUT
AS
-- # Login Disabled for Banned Accounts Start # --
DECLARE @Banned1 int,@Banned2 int,@Banned3 int
SELECT @Banned1 = Authority FROM USERDATA WHERE strUserId = (SELECT strCharID1 FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID AND strCharID1 is not null)
SELECT @Banned2 = Authority FROM USERDATA WHERE strUserId = (SELECT strCharID2 FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID AND strCharID2 is not null)
SELECT @Banned3 = Authority FROM USERDATA WHERE strUserId = (SELECT strCharID3 FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID AND strCharID3 is not null)
IF @Banned1 = 255 OR @Banned2 = 255 OR @Banned3 = 255
BEGIN
-- Blocked Account
SET @nRet = 4
RETURN
END
-- # Login Disabled for Banned Accounts End # --
-- # Auto Account Start #
--SELECT @nRet = Count(strAccountID) FROM TB_USER WHERE strAccountID = @AccountID
--IF @nRet = 0
--BEGIN
--INSERT INTO TB_USER (strAccountID,strPasswd,strSocNo) VALUES (@AccountID,@Password,1)
--END
-- # Auto Account Start #
DECLARE @pwd varchar(21)
SET @pwd = null
SELECT @pwd = strPasswd FROM TB_USER WHERE strAccountID = @AccountID
IF @pwd IS null
BEGIN
-- Invalid Password
SET @nRet = 3
RETURN
END
ELSE IF @pwd <> @Password
BEGIN
-- Invalid Password
SET @nRet = 3
RETURN
END
ELSE IF @pwd = @Password
BEGIN
-- # Check Current User Start #
SELECT @nRet = Count(strAccountId) FROM CURRENTUSER WHERE strAccountId = @AccountID
IF @nRet <> 0
BEGIN
DELETE FROM CURRENTUSER WHERE strAccountID = @AccountID
END
-- # Check Current User End #
-- Login Sucessfull
SET @nRet = 1
RETURN
END
GO