Version 1.3.0

- Implemented authentication and billing routes for Jpn region.
- Refactored and changed the project structure from CommonJS to ES Modules
This commit is contained in:
Junior 2025-04-29 16:20:09 -03:00
parent 9584e58143
commit c3d9e7afb5
76 changed files with 3847 additions and 1109 deletions

View file

@ -0,0 +1,145 @@
-- ----------------------------
-- procedure structure for CreateAccount
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[CreateAccount]') AND type IN ('P', 'PC', 'RF', 'X'))
DROP PROCEDURE[dbo].[CreateAccount]
GO
CREATE PROCEDURE [dbo].[CreateAccount]
@WindyCode varchar(50),
@AccountPwd varchar(255),
@Email varchar(255),
@RegisterIP varchar(16),
@ServerId int,
@ShopBalance Bigint
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Result varchar(20)
DECLARE @EmailExists int;
DECLARE @UsernameExists int;
DECLARE @WindyCodeExists int;
BEGIN TRY
BEGIN TRANSACTION
SELECT @EmailExists = COUNT(*) FROM AccountTable
WHERE Email = @Email;
SELECT @UsernameExists = COUNT(*) FROM AccountTable
WHERE WindyCode = @WindyCode;
SELECT @WindyCodeExists = COUNT(*) FROM RustyHearts_Auth.dbo.AuthTable
WHERE WindyCode = @WindyCode;
-- Check if account exists
IF @EmailExists > 0
SET @Result = 'EmailExists';
ELSE IF @UsernameExists > 0
SET @Result = 'UsernameExists';
ELSE IF @WindyCodeExists > 0
SET @Result = 'UsernameExists';
ELSE
SET @Result = 'NewUser';
-- Create new account
IF @Result = 'NewUser'
BEGIN
INSERT INTO AccountTable (WindyCode, AccountPwd, Email, RegisterIP, CreatedAt, LastLogin, IsLocked, LoginAttempts, LastLoginIP)
VALUES (@WindyCode, @AccountPwd, @Email, @RegisterIP, GETDATE(), GETDATE(), 0, 0, @RegisterIP);
INSERT INTO RustyHearts_Auth.dbo.AuthTable (WindyCode, world_id, AuthID, Tcount, online, CTime, BTime, LTime, IP, LCount, ServerIP, ServerType, HostID, DBCIndex, InquiryCount, event_inquiry, CashMileage, channelling, pc_room_point, externcash, mac_addr, mac_addr02, mac_addr03, second_pass)
VALUES (@WindyCode, 0, NEWID(), 0, '0', GETDATE(), GETDATE(), GETDATE(), @RegisterIP, 0, 0, 0, 0, 0, 5, 1, 0, 1, 0, 0, '00-00-00-00-00-00', '00-00-00-00-00-00', '00-00-00-00-00-00', '');
INSERT INTO CashTable (WindyCode, WorldId, Zen)
VALUES (@WindyCode, @ServerId, @ShopBalance);
SET @Result = 'AccountCreated';
END;
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION;
SET @Result = 'TransactionFailed';
END CATCH
SELECT @Result as Result;
END
GO
-- ----------------------------
-- procedure structure for SetAccountVerificationCode
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[SetAccountVerificationCode]') AND type IN ('P', 'PC', 'RF', 'X'))
DROP PROCEDURE[dbo].[SetAccountVerificationCode]
GO
CREATE PROCEDURE [dbo].[SetAccountVerificationCode]
@VerificationCode varchar(10),
@Email varchar(255),
@ExpirationTime DATETIME
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Result varchar(20)
DECLARE @AccountExists int;
DECLARE @VerificationCodeCount int;
BEGIN TRY
BEGIN TRANSACTION
SELECT @AccountExists = COUNT(*) FROM AccountTable
WHERE Email = @Email;
-- Check if account exists
IF @AccountExists > 0
BEGIN
SET @Result = 'AccountExists';
COMMIT TRANSACTION;
SELECT @Result as Result;
RETURN;
END
IF @Result = 'AccountDontExists'
-- Retrieve count of existing verification codes for the user
SELECT @VerificationCodeCount = COUNT(*) FROM VerificationCode
WHERE Email = @Email;
-- Check if count of existing verification codes is less than 5
IF @VerificationCodeCount < 5
BEGIN
-- Insert new verification code
INSERT INTO VerificationCode (VerificationCode, Email, ExpirationTime, Type)
VALUES (@VerificationCode, @Email, @ExpirationTime, 'Account');
SET @Result = 'Success';
END
ELSE
BEGIN
-- Delete all existing verification codes for the user
DELETE FROM VerificationCode WHERE Email = @Email;
-- Insert new verification code
INSERT INTO VerificationCode (VerificationCode, Email, ExpirationTime, Type)
VALUES (@VerificationCode, @Email, @ExpirationTime, 'Account');
SET @Result = 'Success';
END;
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION;
SET @Result = 'TransactionFailed';
END CATCH
SELECT @Result as Result;
END
GO

View file

@ -1,21 +1,3 @@
/*
Navicat Premium Data Transfer
Source Server : RH VM
Source Server Type : SQL Server
Source Server Version : 16001050
Source Host : 192.168.100.125:1433
Source Catalog : RustyHearts_Account
Source Schema : dbo
Target Server Type : SQL Server
Target Server Version : 16001050
File Encoding : 65001
Date: 12/05/2023 14:59:51
*/
-- ----------------------------
-- Table structure for AccountTable
-- ----------------------------
@ -495,33 +477,40 @@ IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[Cr
GO
CREATE PROCEDURE [dbo].[CreateAccount]
@WindyCode varchar(50),
@AccountPwd varchar(255),
@Email varchar(255),
@RegisterIP varchar(16)
@WindyCode varchar(50),
@AccountPwd varchar(255),
@Email varchar(255),
@RegisterIP varchar(16),
@ServerId int,
@ShopBalance Bigint
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Result varchar(20)
DECLARE @AccountExists int;
DECLARE @EmailExists int;
DECLARE @UsernameExists int;
DECLARE @WindyCodeExists int;
BEGIN TRY
BEGIN TRANSACTION
SELECT @AccountExists = COUNT(*) FROM AccountTable
WHERE WindyCode = @WindyCode OR Email = @Email;
SELECT @EmailExists = COUNT(*) FROM AccountTable
WHERE Email = @Email;
SELECT @UsernameExists = COUNT(*) FROM AccountTable
WHERE WindyCode = @WindyCode;
SELECT @WindyCodeExists = COUNT(*) FROM RustyHearts_Auth.dbo.AuthTable
WHERE WindyCode = @WindyCode;
WHERE WindyCode = @WindyCode;
-- Check if account exists
IF @AccountExists > 0
SET @Result = 'AccountExists';
ELSE IF @WindyCodeExists > 0
SET @Result = 'WindyCodeExists';
IF @EmailExists > 0
SET @Result = 'EmailExists';
ELSE IF @UsernameExists > 0
SET @Result = 'UsernameExists';
ELSE IF @WindyCodeExists > 0
SET @Result = 'UsernameExists';
ELSE
SET @Result = 'NewUser';
@ -535,7 +524,7 @@ BEGIN
VALUES (@WindyCode, 0, NEWID(), 0, '0', GETDATE(), GETDATE(), GETDATE(), @RegisterIP, 0, 0, 0, 0, 0, 5, 1, 0, 1, 0, 0, '00-00-00-00-00-00', '00-00-00-00-00-00', '00-00-00-00-00-00', '');
INSERT INTO CashTable (WindyCode, WorldId, Zen)
VALUES (@WindyCode, 10101, 0);
VALUES (@WindyCode, @ServerId, @ShopBalance);
SET @Result = 'AccountCreated';
@ -664,10 +653,13 @@ BEGIN
-- Check if account exists
IF @AccountExists > 0
SET @Result = 'AccountExists';
ELSE
SET @Result = 'AccountDontExists';
IF @AccountExists > 0
BEGIN
SET @Result = 'AccountExists';
COMMIT TRANSACTION;
SELECT @Result as Result;
RETURN;
END
IF @Result = 'AccountDontExists'
-- Retrieve count of existing verification codes for the user

View file

@ -1,9 +1,8 @@
<?xml version="1.0" ?>
<service>
<active_area country="usa" />
<area country="usa" auth_url="http://localhost:8070/serverApi/auth" billing_url="http://localhost:8080/serverApi/billing" billing_idc="10101" xtrap_use="0" server_mode="WAG" betazone="0" />
<area country="chn" skip_auth="1" free_cash="1" skip_abuse_nick ="1" enc_xml_use ="1" billing_idc="10101" xtrap_use="0" server_mode="WAG" betazone="0" />
<active_area country="jpn" />
<area country="usa" auth_url="http://127.0.0.1:8070/Auth" billing_url="http://127.0.0.1:8070/Billing" billing_idc="10101" xtrap_use="0" server_mode="WAG" betazone="0" />
<area country="jpn" auth_url="http://127.0.0.1:8090/Auth" billing_url="http://127.0.0.1:8090/Billing/" skip_auth="0" skip_billing="0" free_cash="0" skip_abuse_nick="0" second_pass="0" betazone="0" server_mode="WAG" channel_limit_count="1" world_user_limit_count="100" billing_idc="10101" />
<area country="chn" skip_auth="1" free_cash="1" skip_abuse_nick ="1" billing_idc="10101" xtrap_use="0" server_mode="WAG" betazone="0" />
</service>