CREATE PROCEDURE MAIN_LOGIN
@AccountID char(21),
@Password char(21),
@nRet smallint OUTPUT
AS
/*
Author : AKUMA
Update : 30.03.2021 - 11:22
*/
-- # Turkish Character Letters And SQL Injection Disabled Start # --
IF (CHARINDEX('þ',@AccountID) <> 0) OR (CHARINDEX('ı',@AccountID) <> 0) OR
(CHARINDEX('ð',@AccountID) <> 0) OR (CHARINDEX('ö',@AccountID) <> 0) OR
(CHARINDEX('ü',@AccountID) <> 0) OR (CHARINDEX('ç',@AccountID) <> 0) OR
(CHARINDEX('ş',@AccountID) <> 0) OR (CHARINDEX('@',@AccountID) <> 0) OR
(CHARINDEX('+',@AccountID) <> 0) OR (CHARINDEX('-',@AccountID) <> 0) OR
(CHARINDEX('=',@AccountID) <> 0) OR (CHARINDEX('ü',@AccountID) <> 0) OR
(CHARINDEX('ğ',@AccountID) <> 0) OR (CHARINDEX('ı',@AccountID) <> 0) OR
(CHARINDEX('''',@AccountID) <> 0)
BEGIN
SET @nRet = 2
RETURN
END
IF (CHARINDEX('þ',@Password) <> 0) OR (CHARINDEX('ı',@Password) <> 0) OR
(CHARINDEX('ð',@Password) <> 0) OR (CHARINDEX('ö',@Password) <> 0) OR
(CHARINDEX('ü',@Password) <> 0) OR (CHARINDEX('ç',@Password) <> 0) OR
(CHARINDEX('ş',@Password) <> 0) OR (CHARINDEX('@',@Password) <> 0) OR
(CHARINDEX('+',@Password) <> 0) OR (CHARINDEX('-',@Password) <> 0) OR
(CHARINDEX('=',@Password) <> 0) OR (CHARINDEX('ü',@Password) <> 0) OR
(CHARINDEX('ğ',@Password) <> 0) OR (CHARINDEX('ı',@Password) <> 0) OR
(CHARINDEX('''',@Password) <> 0)
BEGIN
SET @nRet = 3
RETURN
END
-- # Turkish Character Letters and SQL Injection Disabled End # --
-- # 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,idays) VALUES (@AccountID,@Password,1,6)
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