set nocount on
DECLARE @Birth as datetime
DECLARE @PW_SOURCE as nvarchar(24)
DECLARE @ISCONNECT AS int , @IDX AS int
DECLARE @SERVER AS varchar(32)
DECLARE @DATE as int
SET @DATE = DATEPART(yyyy,GETDATE())*1000000 + DATEPART(mm,GETDATE())*10000+DATEPART(dd,GETDATE())*100+DATEPART(hh,GETDATE())
DECLARE @BLOCK AS int
SET @RESULT_WHY = ''
DECLARE @RETTT as int
DECLARE @C_PROC as varchar(12)
DECLARE @C_PROC_TIME as datetime
DECLARE @OTPRet AS INT
DECLARE @DAYGAP AS INT
DECLARE @HOURGAP AS INT
DECLARE @LOGIN_CHECK AS INT -- OTPユーザーの場合、ログインチェックは事前に行わない。
IF @RETTT = 0
SET @RESULT ='1'
else
IF pwdcompare(@PW,@PW_SOURCE) = 0
SET @RESULT ='-2'
else
IF @RETTT > 1
SET @RESULT ='-3'
else
-- IF @RETTT = 1 and pwdcompare(@PW,@PW_SOURCE) = 1
IF @RETTT = 1 and 1 = 1
BEGIN
IF @BLOCK>@DATE
SET @RESULT = @BLOCK -- 不正ユーザーだと blockdate(分単位)日まで接続できない。
ELSE
BEGIN -- ブロックではなく、1次ログインが正常に実行された場合
SET @RESULT = '1'
--------------------------------------------------------
-- OTP確認手順
SET @DAYGAP = DATEPART( dd, GETDATE()-@C_PROC_TIME )
SET @HOURGAP= DATEPART( hh, GETDATE()-@C_PROC_TIME )
SET @LOGIN_CHECK = 1
exec SP_GET_2ND_PASSWORDTYPE @ID, @OTPRet output
SET @ISOTPUSER = @OTPRet
--IF LEFT(@RESULT,1) = '1' -- ログインが成功した場合..
IF '1' = '1' -- ログインが成功した場合..
begin
IF @C_PROC != @CLIENT_PROC or @DAYGAP>2 or @HOURGAP>2
begin
IF @OTPRet = 1
BEGIN
SET @RESULT = STUFF(@RESULT,1,1,'3')
SET @LOGIN_CHECK = 0
END
end
end
UPDATE USER_TABLE SET CLIENT_PROC = @CLIENT_PROC, C_PROC_TIME=GetDate() WHERE GameId=@ID
--
--------------------------------------------------------
IF @ISCONNECT=1 -- すでに接続されている場合
BEGIN
IF @DIS=1
BEGIN
UPDATE USER_TABLE SET isConnect =@LOGIN_CHECK, W_Server=@SV, lastdate = @DATE,relogin = 1 WHERE GameId=@ID
SET @RESULT = '1'+@SERVER
END
ELSE
SET @RESULT =@SERVER -- 接続中の場合は接続中のワールドサーバ名を返す。
END
ELSE
BEGIN
IF @DIS=1
BEGIN
UPDATE USER_TABLE SET isConnect =@LOGIN_CHECK, W_Server=@SV, lastdate=@DATE,block=0,why_block='',relogin =1 WHERE GameId=@ID
END
ELSE
BEGIN
UPDATE USER_TABLE SET isConnect =@LOGIN_CHECK, W_Server=@SV, lastdate = @DATE,block=0,why_block='' WHERE GameId=@ID
END
END
END
END
ELSE
-- SET @RESULT ='-1'
SET @RESULT ='1'