diff --git a/Back/mobile_proc_userLogin.sql b/Back/mobile_proc_userLogin.sql new file mode 100644 index 0000000..65c6ee2 --- /dev/null +++ b/Back/mobile_proc_userLogin.sql @@ -0,0 +1,913 @@ +USE [FastMoneyPro_Remit] +GO + +/****** Object: StoredProcedure [dbo].[mobile_proc_userLogin] Script Date: 12/11/2023 2:04:40 PM ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + + + +ALTER PROCEDURE [dbo].[mobile_proc_userLogin] @flag VARCHAR(30) + ,@userName VARCHAR(100) = NULL + ,@Password VARCHAR(100) = NULL + ,@Imei VARCHAR(256) = NULL --Imei Number/UUID or Android id of Mobile + ,@accessCode VARCHAR(MAX) = NULL -- access token used in every request + ,@scope VARCHAR(50) = NULL --for mobile applicatin, @scope='mobile_app' + ,@clientId VARCHAR(200) = NULL --basic header key + ,@fcmid VARCHAR(250) = NULL + ,@customerId VARCHAR(100) = NULL + ,@ip VARCHAR(100) = NULL + ,@isBiometricLogin VARCHAR(5) = NULL + ,@biometricLoginType VARCHAR(20) = NULL + ,@deviceType VARCHAR(100) = NULL + ,@accessToken VARCHAR(MAX) = NULL -- access token for Biometric + ,@residenceType VARCHAR(20) = NULL +AS +BEGIN TRY + ---------------------------------------- + --@fcmid varchar(250), add @IP param + --#182 - @isBiometricLogin VARCHAR(5), @biometricLoginType VARCHAR(20) , modifications in @flag='l' + -- @isbiometricEnabled + -- #225 - flag = l, check accessCode and status for biometric login + -- add new param @accessToken for Biometric + --select column [mobile_userRegistration].isForcePassChange + --#101 , #361 - Mobile changes for multi lingual + --#101 -set biometric as empty for '5' ErrorCode + --No email OTP verification was prompt for existing customer which was activate over the counter. + --#665 Remove JME online from Branch list + --add for trustdoc @residenceType + ---------------------------------------- + SET NOCOUNT ON; + SET XACT_ABORT ON; + + DECLARE @UserData VARCHAR(500) + ,@UserInfoDetail VARCHAR(MAX) + ,@AccessCodeExpiresAfter INT = 5 --Minutes + ,@email VARCHAR(100) + ,@mobile VARCHAR(100) + ,@customerPwd VARCHAR(50) + ,@isActive CHAR(1) + ,@isEmailVerified BIT + ,@approvedDate DATETIME + ,@isBiometricEnabled VARCHAR(10) + --,@customerStatus VARCHAR(5) + ----------------------- Local variables declaration ###STARTS------------------------ + DECLARE @_imei VARCHAR(256) + ,@_otpUsed BIT + ,@_scope VARCHAR(50) + ,@_isDeleted CHAR(1) + ,@_errorMsg VARCHAR(MAX) + ,@_isExists BIT = 0 + ,@_Otp VARCHAR(50) + ,@_accessCode VARCHAR(MAX) + ,@_accessCodeExpiry DATETIME + ,@_errorCode VARCHAR(20) + ,@_lastLoggedInDevice VARCHAR(200) + ,@previousAccessCode VARCHAR(MAX) + + ----------------------- Local variables declaration ###ENDS------------------------ + -- Check This Customer Infoagree State + IF @flag = 'check-agree' + BEGIN + IF EXISTS ( + SELECT TOP 1 'X' + FROM CustomerMasterTemp(NOLOCK) + WHERE username = @userName + AND ISNULL(agreeYn, '0') = '0' + ) + BEGIN + SELECT 0 ErrorCode + ,'Get PDF List Success About Agree infomation' Msg + ,NULL Id + ,rowId + ,PdfName + ,AgreePdfPath + FROM customerAgreeDocumentTbl(NOLOCK) + WHERE targetObj = 'STAGING' + + RETURN + END + ELSE IF EXISTS ( + SELECT TOP 1 'X' + FROM CustomerMaster(NOLOCK) + WHERE email = @userName + AND ISNULL(agreeYn, '0') = '0' + ) + BEGIN + SELECT 0 ErrorCode + ,'Get PDF List Success About Agree infomation' Msg + ,NULL Id + ,rowId + ,PdfName + ,AgreePdfPath + FROM customerAgreeDocumentTbl(NOLOCK) + WHERE targetObj = 'STAGING' + + RETURN + END + ELSE + BEGIN + SELECT 1 ErrorCode + ,'Invaild user.. Check user value ' Msg + ,NULL Id + END + END + ELSE IF @flag = 'l' -- login to system(done) + BEGIN + IF ISNULL(@username, '') = '' + BEGIN + SELECT '1' ErrorCode + ,'User Id not defined.' Msg + ,NULL ID + + RETURN + END + + --IF EXISTS(SELECT * FROM customerMaster WHERE email = @userName AND ISNULL(mobileUser,'N') = 'N') + --BEGIN + + -- SELECT '20' errorCode + -- ,'Your JME account is disabled. Contact JME support.' msg + -- ,@username id + + -- SET @UserInfoDetail = 'Reason = Login fails, Your mobile login is disabled. Please, contact your administrator.' + + -- EXEC proc_applicationLogs @flag = 'login' + -- ,@logType = 'Login fails' + -- ,@createdBy = @userName + -- ,@Reason = 'Mobile login is disabled ' + -- ,@UserData = @UserData + -- ,@fieldValue = @UserInfoDetail + + -- RETURN + + --END + + SELECT @scope = dbo.mobile_FNAGetApplicationScope(@clientId) + + IF ISNULL(@scope, '') <> 'mobile_app' + BEGIN + SELECT '2' ErrorCode + ,'Application scope is not valid for this user.' Msg + ,NULL ID + + RETURN + END + + SET @UserData = 'User: ' + @username + ' ,Password: ' + @Password + ' ,User Type:Mobile User' + ' ,Device Info: ' + @imei + ' ,IsBiometricLogin: ' + @isBiometricLogin + ' ,BiometricTypeLogin: ' + @biometricLoginType + ' ,DeviceType: ' + @deviceType + ' ,AccessCode: ' + ISNULL(@accessCode, '') + ' ,AccessToken: ' + ISNULL(@accessToken, '') + + DECLARE @isReferred BIT = 0 + + IF EXISTS ( + SELECT TOP 1 'x' + FROM referralmaster(NOLOCK) + WHERE email = @userName + OR mobile = @userName + ) + SET @isReferred = 1 + + SELECT @_lastLoggedInDevice = lastLoggedInDevice + ,@_accessCodeExpiry = accessCodeExpiry + ,@_accessCode = accessCode + FROM dbo.mobile_userRegistration(NOLOCK) + WHERE username = @userName + + --IF @_lastLoggedInDevice = @Imei AND @_accessCodeExpiry > GETDATE() + --BEGIN + -- SET @accessCode=@_accessCode + -- UPDATE mobile_userRegistration SET + -- accessCodeExpiry = DATEADD(MINUTE,@AccessCodeExpiresAfter,GETDATE()) --adding validity of access token for 20 minutes. + -- FROM dbo.mobile_userRegistration(NOLOCK) ur + -- WHERE ur.username = @userName --END + --ELSE + DECLARE @JmeclientId VARCHAR(50) + + SELECT @JmeclientId = DBO.DECRYPTDB(clientId) + FROM KFTC_GME_MASTER(NOLOCK) + + BEGIN + BEGIN TRANSACTION + + IF @ResidenceType='0' + SET @ResidenceType = NULL + ELSE IF @ResidenceType='RESIDENCE' -- JAPANESE + SET @ResidenceType = 'RESIDENT' /*ANDROID*/ + + UPDATE mobile_userRegistration + SET accessCode = @accessCode + ,accessCodeExpiry = DATEADD(MINUTE, @AccessCodeExpiresAfter, GETDATE()) --adding validity of access token for 20 minutes. + ,IMEI = @Imei + ,lastLoggedInDevice = getdate() + ,deviceId = ISNULL(@fcmid, deviceId) + ,ipAddress = @ip + ,BiometricLoginType = @biometricLoginType + --,IsBiometricLogin = @isBiometricLogin + ,DeviceType = @deviceType + ,modifiedDate=GETDATE() + ,ResidenceType=CASE WHEN @ResidenceType IS NOT NULL THEN @ResidenceType WHEN @ResidenceType='0' THEN ResidenceType ELSE ResidenceType END + FROM dbo.mobile_userRegistration(NOLOCK) + WHERE username = @userName + + IF @@TRANCOUNT > 0 + COMMIT TRANSACTION + END + + DELETE T + FROM customerMaster(NOLOCK) c + INNER JOIN CustomerMasterTemp t ON c.username = t.username + AND C.username = @userName + + DECLARE @redirectTo VARCHAR(100) = 'EYKC'; + + IF EXISTS ( + SELECT TOP 1 'X' + FROM customerMasterTemp cm(NOLOCK) + WHERE cm.username = @userName + AND cm.customerPassword = dbo.FNAEncryptString(@Password) + ) + OR ( + EXISTS ( + SELECT TOP 1 'X' + FROM customerMasterTemp cm(NOLOCK) + INNER JOIN MobileToken mt(NOLOCK) ON cm.email = mt.userName + WHERE cm.username = @userName + AND @isBiometricLogin = 'TRUE' + AND mt.token = @accessToken + AND mt.activeStatus = 'Y' + ) + ) + BEGIN + + SELECT '0' ErrorCode + ,'a' scope + ,@userName userId + ,cust.customerId SenderId + ,ISNULL(cust.firstName, '') firstName + -- ,ISNULL(cust.middleName,'') middleName + -- ,ISNULL(cust.lastName1,'') lastName + -- ,ISNULL(cust.nickName,'') nickName + ,ISNULL(cust.email, '') email + ,ISNULL(cust.customerEmail, '') customerEmail + ,ISNULL(cust.mobile, '') phone + -- ,cust.idType AS idType + --,cust.idNumber AS idNumber + ,cm.countryCode AS countryCode + -- ,CAST(ISNULL(cust.bonusPoint,0) AS DECIMAL) rewardPoint + ,CASE + WHEN ISNULL(cust.isActive, 'Y') = 'Y' + THEN 1 + ELSE 0 + END active + ,kyc = 0 + ,CASE + WHEN ISNULL(cust.verifiedDate, '') <> '' + THEN 1 + ELSE 0 + END verified + ,ISNULL(cust.walletAccountNo, '') walletNumber + ,0 availableBalance + ,'Fast Remit Bank' primaryBankName + -- ,'' primaryBankAccount + ,@accessCode accessCode + ,DATEDIFF(SS, GETDATE(), ur.accessCodeExpiry) expiresIn + -- ,ISNULL(dpUrl,'') dpUrl + -- ,ISNULL(ur.cmRegistrationId,'') cmRegistrationId + ,'' country + ,ISNULL(cust.city, '') city + ,ISNULL(cust.[address], '') [address] + -- ,ISNULL(cust.state2,'') [province] + ,'' [provinceId] + -- ,@isReferred isReferred + ,'' sourceId + ,yearlyLimit = 0 + ,'0' AS pennyTestStatus + ,gmeClientId = @JmeclientId + ,redirectTo = @redirectTo + ,cust.customerType + ,ISNULL(ur.ResidenceType,'FOREIGNER') ResidenceType + ,isExistingCustomer = ISNULL(isExistingCustomer, 1) + ,IsBiometricLogin = ISNULL(IsBiometricLogin, 0) + ,BiometricLoginType = ISNULL(BiometricLoginType, '') + --,@customerStatus= ISNULL(customerStatus,'') + ,CASE ur.isForcePassChange + WHEN '1' + THEN 'Y' + ELSE 'N' + END IsForcedPwdChange + ,ISNULL(@accessToken, '') accessToken + FROM ( + SELECT TOP 1 * + FROM customerMasterTemp(NOLOCK) cust + WHERE cust.username = @userName + ) cust + LEFT JOIN mobile_userRegistration(NOLOCK) ur ON cust.customerId = ur.customerId + LEFT JOIN dbo.countryMaster(NOLOCK) AS CM ON cm.countryId = cust.nativeCountry + --PRINT @ResidenceType + --UPDATE customerMasterTemp SET idType =CASE WHEN @ResidenceType='FOREIGNER' THEN 11168 + --WHEN @ResidenceType IN('JAPANESE','RESIDENCE','RESIDENT') THEN 11079 ELSE 11168 END + --WHERE username = @userName + + --WHERE cust.username=@userName + EXEC proc_applicationLogs @flag = 'login' + ,@logType = 'Login Success' + ,@createdBy = @username + ,@Reason = 'Login' + ,@UserData = @UserData + ,@fieldValue = @UserInfoDetail + + RETURN + END + + IF UPPER(@isBiometricLogin) = 'TRUE' + BEGIN + SELECT @isbiometricEnabled = ( + SELECT ISNULL(isBiometricLogin, 0) + FROM mobile_userRegistration + WHERE username = @userName + ) + + IF @isbiometricEnabled = 0 + BEGIN + SELECT '3' ErrorCode + ,'Fingerprint login is not enabled. Please login using password.' Msg + ,NULL ID + + RETURN + END + + IF ISNULL(@accessToken, '') = '' + BEGIN + SELECT '4' ErrorCode + ,'Access Token is required for Fingerprint login.' Msg + ,NULL ID + + RETURN + END + + IF NOT EXISTS ( + SELECT TOP 1 * + FROM MobileToken(NOLOCK) + WHERE userName = @userName + AND token = @accessToken + AND activeStatus = 'Y' + ) + BEGIN + UPDATE mobile_userRegistration SET isBiometricLogin=0,BiometricLoginType=null,DeviceType=null, modifiedDate=GETDATE(), modifiedby= @userName + WHERE username = @userName + + SELECT '5' ErrorCode + ,'Unauthorized Login for Fingerprint login. Please login using password.' Msg + ,NULL + + RETURN + END + + SELECT @email = email + ,@mobile = cm.mobile + ,@customerPwd = customerPassword + ,@isActive = isactive + ,@customerId = cm.customerId + ,@approvedDate = cm.approvedDate + FROM customerMaster(NOLOCK) cm + WHERE cm.username = @userName + -- AND ISNULL(cm.mobileUser,'Y') = 'Y' + END + ELSE + BEGIN + SELECT @email = email + ,@mobile = cm.mobile + ,@customerPwd = customerPassword + ,@isActive = isactive + ,@customerId = cm.customerId + ,@approvedDate = cm.approvedDate + --,@customerStatus=ISNULL(customerStatus,'') + FROM customerMaster(NOLOCK) cm + WHERE cm.username = @userName + --OR cm.mobile=@userName ## NOT MOBILE LOGIN NOT APPLICABLE + AND cm.customerPassword = dbo.FNAEncryptString(@Password) + -- AND ISNULL(cm.mobileUser,'Y')='Y' + END + + IF @customerId IS NULL --OR @activeStatus = 'N' + BEGIN + SELECT '6' errorCode,'The username/password do not match.' msg + + SET @UserInfoDetail = 'Reason = Incorrect username.' + + EXEC dbo.proc_applicationLogs @flag = 'login' + ,@logType = 'Login fails' + ,@createdBy = @username + ,@Reason = 'Invalid Username' + ,@UserData = @UserData + ,@fieldValue = @UserInfoDetail + + RETURN + END + + DECLARE @isMobileLoginEnabled VARCHAR(1) + + IF EXISTS(SELECT * FROM customerMasterTemp WHERE email = @userName AND ISNULL(mobileUser,'Y') = 'N') + BEGIN + SELECT @isMobileLoginEnabled = 'N' + END + ELSE + SELECT @isMobileLoginEnabled = 'Y' + IF EXISTS(SELECT * FROM customerMaster WHERE email = @userName AND ISNULL(mobileUser,'Y') = 'N') + BEGIN + SELECT @isMobileLoginEnabled = 'N' + END + ELSE + SELECT @isMobileLoginEnabled = 'Y' + + IF @isMobileLoginEnabled = 'N' + BEGIN + SELECT '20' errorCode + ,'Your JME account is disabled. Contact JME support.' msg + ,@username id + + SET @UserInfoDetail = 'Reason = Login fails, Your mobile login is disabled. Please, contact your administrator.' + + EXEC proc_applicationLogs @flag = 'login' + ,@logType = 'Login fails' + ,@createdBy = @userName + ,@Reason = 'Mobile login is disabled ' + ,@UserData = @UserData + ,@fieldValue = @UserInfoDetail + + RETURN + END + + BEGIN TRANSACTION + + IF NOT EXISTS ( + SELECT TOP 1 'X' + FROM mobile_userRegistration ur(NOLOCK) + WHERE ur.username = @userName + ) + BEGIN + INSERT INTO mobile_userRegistration ( + customerId + ,username + ,OTP + ,OTP_Used + ,createdDate + ,IMEI + ,clientId + ,deviceId + ,ipAddress + ,BiometricLoginType + ,IsBiometricLogin + ,DeviceType + ,ResidenceType + ) + SELECT @customerId + ,@userName + ,0 + ,0 + ,GETDATE() + ,@Imei + ,@clientId + ,@fcmid + ,@ip + ,@biometricLoginType + ,@isBiometricLogin + ,@deviceType + ,@residenceType + + UPDATE cm + SET cm.isEmailVerified = 1 + FROM dbo.customerMaster cm + WHERE cm.customerId = @customerId AND ISNULL(cm.customerStatus,'')<>'OTC' + + END + + IF @@TRANCOUNT > 0 + COMMIT TRANSACTION + + DECLARE @attemptsCount INT + + SELECT TOP 1 @attemptsCount = loginAttemptCount + FROM passwordFormat WITH (NOLOCK) + + IF (ISNULL(@isActive, 'Y') = 'N') + BEGIN + SELECT '7' errorCode + ,'Your account is Inactive. Please, contact JME Support Team.' msg + ,@userName id + + SET @UserInfoDetail = 'Reason = Login fails, Your account is Inactive. Please, contact your administrator.' + + EXEC proc_applicationLogs @flag = 'login' + ,@logType = 'Login fails' + ,@createdBy = @userName + ,@Reason = 'User is not active ' + ,@UserData = @UserData + ,@fieldValue = @UserInfoDetail + + RETURN + END + + + UPDATE customerMaster + SET lastLoginTs = GETDATE() + --,idType =CASE WHEN @ResidenceType='FOREIGNER' THEN 11168 WHEN @ResidenceType='JAPANESE' THEN 11079 ELSE idType END + WHERE customerId = @customerId + + DECLARE @yearlyLimit VARCHAR(100) = '' + DECLARE @totalSend MONEY + ,@totalSendText VARCHAR(200) + ,@YearStart DATE + ,@YearEnd DATETIME + + SELECT @YearStart = DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0) + ,@YearEnd = DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, - 1) + ' 23:59:59' + + SELECT @totalSend = SUM(R.cAmt) + FROM REMITTRAN R(NOLOCK) + INNER JOIN TRANSENDERS T(NOLOCK) ON T.TRANID = R.ID + AND T.CUSTOMERID = @customerId + AND R.TRANSTATUS <> 'Cancel' + AND R.approvedDate BETWEEN @YearStart + AND @YearEnd + + SELECT @yearlyLimit = amount + FROM dbo.csDetail CD(NOLOCK) + INNER JOIN csMaster CM(NOLOCK) ON CM.csMasterId = CD.csMasterId + AND CD.period = 365 + AND CD.condition = 4600 + AND ISNULL(CD.isActive, 'Y') = 'Y' + AND ISNULL(CD.isDeleted, 'N') = 'N' + AND ISNULL(CD.isEnable, 'Y') = 'Y' + AND ISNULL(CM.isActive, 'Y') = 'Y' + AND ISNULL(CM.isDeleted, 'N') = 'N' + + SET @yearlyLimit = (@yearlyLimit - ISNULL(@totalSend, 0)) + + DECLARE @hasPennyTestDone VARCHAR(1) = '1' + + --IF EXISTS ( + -- SELECT TOP 1 'x' + -- FROM dbo.customerMaster(NOLOCK) + -- WHERE approvedDate < '2018-12-19' + -- AND customerId = @customerId + -- ) + --BEGIN + -- SET @hasPennyTestDone = '2' + --END + + SELECT '0' ErrorCode + ,@scope scope + ,@userName userId + ,cust.customerId SenderId + ,ISNULL(cust.firstName, '') firstName + -- ,ISNULL(cust.middleName,'') middleName + -- ,ISNULL(cust.lastName1,'') lastName + -- ,'' nickName + ,ISNULL(cust.email, '') email + ,ISNULL(cust.customerEmail, '') customerEmail + ,ISNULL(cust.mobile, '') phone + -- ,cust.idType AS idType + --,cust.idNumber AS idNumber + ,cm1.countryCode AS countryCode + ,CAST(ISNULL(cust.bonusPoint, 0) AS DECIMAL) rewardPoint + ,CASE + WHEN ISNULL(cust.isActive, 'Y') = 'Y' + THEN 1 + ELSE 0 + END active + ,ISNULL(HasDeclare, 0) kyc + ,CASE + WHEN ISNULL(isExistingCustomer, 1) = 0 + THEN CASE + WHEN cust.ApprovedDate IS NOT NULL + THEN 1 + ELSE 0 + END + ELSE CASE + WHEN mobileVerifiedDate IS NOT NULL + THEN 1 + ELSE 0 + END + END verified + ,ISNULL(cust.walletAccountNo, '') walletNumber + ,CAST([dbo].FNAGetCustomerACBal(@email) AS DECIMAL) availableBalance + --,ISNULL(bl.BankName,'') primaryBankName + ,primaryBankName = 'Fast Remit Bank' --CASE WHEN cust.customerType='11048' THEN 'Mutual savings bank' ELSE 'Kwangju Bank (034)' END + -- ,'' AS primaryBankAccount + ,@accessCode accessCode + ,DATEDIFF(SS, GETDATE(), ur.accessCodeExpiry) expiresIn + -- ,'' dpUrl + -- ,ISNULL(ur.cmRegistrationId,'') cmRegistrationId + ,ISNULL(co.countryName, '') country + ,ISNULL(cust.city, '') city + ,ISNULL(cust.[address], '') [address] + -- ,ISNULL(cust.state2,'') [province] + ,ISNULL(cm.cityId, '') [provinceId] + -- ,@isReferred isReferred + ,ISNULL(sdv.valueId, '') sourceId + ,yearlyLimit = @yearlyLimit + ,PennyTestStatus = @hasPennyTestDone -----0 not started, 1 requested , 2 completed + ,gmeClientId = @JmeclientId + ,redirectTo = @redirectTo + ,cust.customerType + ,ISNULL(ur.ResidenceType,'FOREIGNER') ResidenceType + ,isExistingCustomer = ISNULL(isExistingCustomer, 1) + ,IsBiometricLogin = ISNULL(IsBiometricLogin, 0) + ,BiometricLoginType = ISNULL(BiometricLoginType, '') + ,CASE ur.isForcePassChange + WHEN '1' + THEN 'Y' + ELSE 'N' + END IsForcedPwdChange + ,ISNULL(@accessToken, '') accessToken + FROM ( + SELECT TOP 1 * + FROM customerMaster(NOLOCK) cust + WHERE cust.customerId = @customerId + ) cust + LEFT JOIN dbo.countryMaster AS CM1 ON cm1.countryId = cust.nativeCountry + LEFT JOIN mobile_userRegistration(NOLOCK) ur ON cust.customerId = ur.customerId + LEFT JOIN dbo.vwBankLists(NOLOCK) bl ON cust.bankName = bl.bankCode + LEFT JOIN countryMaster co(NOLOCK) ON cust.country = co.countryId + LEFT JOIN staticDatavalue sdv(NOLOCK) ON cust.sourceOfFund = sdv.detailTitle + AND ISNULL(sdv.IS_DELETE, 'N') = 'N' + LEFT JOIN dbo.CityMaster cm(NOLOCK) ON cust.state2 = cm.cityName + + --WHERE cust.customerId=@customerId AND ISNULL(sdv.IS_DELETE,'N')='N' + EXEC proc_applicationLogs @flag = 'login' + ,@logType = 'Login Success' + ,@createdBy = @username + ,@Reason = 'Login' + ,@UserData = @UserData + ,@fieldValue = @UserInfoDetail + + RETURN + END + ELSE IF @flag = 'chk-access-code' --validating access code(done) + BEGIN + --SELECT + -- @_accessCodeExpiry=l.accessCodeExpiry + -- ,@username=ISNULL(l.username,cust.email) + -- ,@_scope=ISNULL(a.scope,'') + -- ,@_lastLoggedInDevice=ISNULL(cust.lastLoggedInDevice,'') + -- ,@_imei =ISNULL(cust.lastLoggedInDevice,'') + --FROM customermasterTemp(NOLOCK) cust + --INNER JOIN customermaster(NOLOCK) main ON main.customerId=cust.customerMasterId + --LEFT JOIN mobile_userRegistration(NOLOCK) l ON cust.customerId=l.customerId + --INNER JOIN mobile_GmeApiClientRegistration a(NOLOCK) ON a.clientId=l.clientId + --WHERE l.accessCode=@accessCode + SELECT @_accessCodeExpiry = MUR.accessCodeExpiry + ,@username = mur.username + ,@_scope = ISNULL(a.scope, '') + ,@_lastLoggedInDevice = mur.lastLoggedInDevice + ,@_imei = mur.IMEI + ,@customerId = mur.rowId + FROM dbo.mobile_userRegistration AS MUR(NOLOCK) + INNER JOIN mobile_GmeApiClientRegistration a(NOLOCK) ON a.clientId = MUR.clientId + AND MUR.accessCode = @accessCode + AND ( + mur.IMEI = @Imei + OR mur.lastLoggedInDevice = @Imei + ) + + --PRINT @_accessCodeExpiry + --IF NOT EXISTS(SELECT 'x' FROM dbo.mobile_userRegistration AS MUR WHERE MUR.accessCode=@accessCode AND MUR.IMEI=@Imei) + --BEGIN + -- SELECT '2' errorCode, 'Access code expired..' Msg ,NULL ID + -- RETURN + --END + --IF NOT EXISTS(SELECT 'x' FROM dbo.mobile_userRegistration AS MUR WHERE MUR.accessCode=@accessCode AND MUR.lastLoggedInDevice=@Imei) + --BEGIN + -- SELECT '2' errorCode, 'Access code expired..' Msg ,NULL ID + -- RETURN + --END + IF ISNULL(@username, '') = '' + AND ISNULL(@_lastLoggedInDevice, '') = @imei + BEGIN + SELECT '8' errorCode + ,'Access code expired..' Msg + ,NULL ID + + RETURN + END + + IF ISNULL(@username, '') = '' + AND ISNULL(@_lastLoggedInDevice, '') <> @imei + BEGIN + SELECT '9' errorCode + ,'Access code expired..' Msg + ,NULL ID + + RETURN + END + + IF (@_accessCodeExpiry < GETDATE()) + BEGIN + SELECT '10' errorCode + ,'It seems like you are using old access code. Please use newly generated access code.' Msg + ,NULL ID + + RETURN + END + + ------------- ### Check if the user trying to validate access-code exists or not ###STARTS------------ + IF @username IS NULL + BEGIN + SELECT @_errorMsg = 'User with contact Info ' + @username + ' doesnot exists. If you are a new user, then sign up and proceed further.' + + SELECT '1' ErrorCode + ,@_errorMsg Msg + ,NULL ID + + RETURN + END + + ------------- ### Check if the user trying to validate access-code exists or not ###ENDS------------ + IF @_lastLoggedInDevice <> @Imei + BEGIN + SELECT '11' errorCode + ,'You are logged in from another device.' Msg + ,NULL ID + + RETURN + END + ELSE IF ISNULL(@_scope, '') <> 'mobile_app' + BEGIN + SELECT '12' ErrorCode + ,'Application scope is not valid for this user.' Msg + ,NULL ID + + RETURN + END + + UPDATE mobile_userRegistration + SET accessCodeExpiry = DATEADD(MINUTE, @AccessCodeExpiresAfter, GETDATE()) --expiry time for access code(token) increased to 20 minutes. + WHERE rowId = @customerId + + SELECT '0' ErrorCode + ,'Success' Msg + ,@_scope ID + + RETURN + END + ELSE IF @flag = 's-accesscode' --validating accessCode for "Get user by access code" + BEGIN + IF @scope <> 'social_comp' + BEGIN + SELECT '13' ErrorCode + ,'Application scope is not valid for this user.' Msg + ,NULL ID + + RETURN + END + + DECLARE @user VARCHAR(100); + + SELECT @email = cm.email + ,@mobile = cm.mobile + ,@isEmailVerified = cm.isEmailVerified + ,@customerId = cm.customerId + FROM dbo.customerMaster(NOLOCK) cm + INNER JOIN dbo.mobile_userRegistration(NOLOCK) ur ON cm.customerId = ur.customerId + AND ur.accessCode = @accessCode + + IF @email IS NOT NULL + AND @isEmailVerified = 1 + BEGIN + SET @user = @email + END + ELSE + BEGIN + SET @user = @mobile + END + + SELECT @_imei = l.imei + ,@_accessCodeExpiry = l.accessCodeExpiry + ,@username = @user + FROM customermaster cust(NOLOCK) + INNER JOIN mobile_userRegistration l(NOLOCK) ON cust.customerId = l.customerId + AND l.accessCode = @accessCode + + IF DATEDIFF(MINUTE, GETDATE(), @_accessCodeExpiry) > 0 + BEGIN + SELECT '0' ErrorCode + ,@userName userId + ,ISNULL(cust.firstName, '') firstName + ,ISNULL(cust.middleName, '') middleName + ,ISNULL(cust.lastName1, '') lastName + ,ISNULL(cm.countryName, '') nativeCountry + ,'' nickName + ,userRoles = '' + ,'' dpUrl + ,ISNULL(ur.cmRegistrationId, '') cmRegistrationId + ,ISNULL(ur.IMEI, '') uuid + FROM ( + SELECT TOP 1 * + FROM customerMaster(NOLOCK) cust + WHERE cust.customerId = @customerId + ) cust + LEFT JOIN mobile_userRegistration ur(NOLOCK) ON cust.customerId = ur.customerId + LEFT JOIN dbo.countryMaster cm(NOLOCK) ON cust.nativeCountry = cm.countryId + + --WHERE cust.customerId=@customerId + --WHERE cust.email=@userName OR cust.mobile=@userName + RETURN + END + ELSE IF DATEDIFF(MINUTE, GETDATE(), @_accessCodeExpiry) <= 0 + BEGIN + SELECT '14' ErrorCode + ,'Access code expired.' Msg + ,NULL ID + + RETURN + END + ELSE + BEGIN + SELECT '15' ErrorCode + ,'Access code does not match.' Msg + ,NULL ID + + RETURN + END + END + ELSE IF @flag = 'ckeck-guid' + BEGIN + IF EXISTS ( + SELECT TOP 1 'A' + FROM dbo.mobile_userRegistration(NOLOCK) + WHERE accessCode IS NULL + AND username = @userName + ) + BEGIN + UPDATE dbo.mobile_userRegistration + SET accessCode = @accessCode + WHERE accessCode IS NULL + AND username = @userName + END + + IF EXISTS ( + SELECT TOP 1 'A' + FROM dbo.mobile_userRegistration(NOLOCK) + WHERE accessCode = @accessCode + AND username = @userName + ) + BEGIN + SELECT '0' ErrorCode + ,'The access code is valid and is from trusted customer.' Msg + ,NULL Id + + RETURN + END + + BEGIN + SELECT '1' ErrorCode + ,'No such access code found in system. Invalid username and customer is not trusted.' Msg + ,NULL Id + + RETURN + END + END + ELSE IF @flag = 'get-device' + BEGIN + SELECT deviceId + FROM mobile_userRegistration(NOLOCK) + WHERE customerId = @customerId + + RETURN + END + ELSE IF @flag = 'agentDetail' + BEGIN + SELECT agentId + ,agentName + ,agentState + ,agentCity + ,agentAddress + ,agentZip + ,agentPhone1 + FROM AGENTMASTER(NOLOCK) + WHERE PARENTID = '393877' + and agentid<>'394395' + AND ACTASBRANCH = 'Y' + + RETURN + END +END TRY + +BEGIN CATCH + IF @@TRANCOUNT > 0 + ROLLBACK TRANSACTION + + DECLARE @errorMessage VARCHAR(MAX) + + SET @errorMessage = ERROR_MESSAGE() + + SELECT '1' ErrorCode + ,@errorMessage Msg + ,NULL ID +END CATCH + +GO + diff --git a/Back/proc_online_core_customerSetup.sql b/Back/proc_online_core_customerSetup.sql new file mode 100644 index 0000000..2dfdc0b Binary files /dev/null and b/Back/proc_online_core_customerSetup.sql differ diff --git a/Back/proc_online_customer_login.sql b/Back/proc_online_customer_login.sql new file mode 100644 index 0000000..e9965af --- /dev/null +++ b/Back/proc_online_customer_login.sql @@ -0,0 +1,500 @@ +USE [FastMoneyPro_Remit] +GO + +/****** Object: StoredProcedure [dbo].[proc_online_customer_login] Script Date: 12/11/2023 2:10:25 PM ******/ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + + + +ALTER PROC [dbo].[proc_online_customer_login] + @flag VARCHAR(50) + ,@customerEmail VARCHAR(100) = NULL + ,@customerPassword VARCHAR(255) = NULL + ,@country VARCHAR(50) = NULL + ,@ipAddress VARCHAR(100) = NULL + ,@lockReason VARCHAR(500) = NULL + ,@UserInfoDetail VARCHAR(MAX) = NULL + ,@sessionId VARCHAR(60) = NULL + ,@checkCountry VARCHAR(50) = NULL + ,@password VARCHAR(50) = NULL + ,@idType VARCHAR(50) = NULL + ,@idNumber VARCHAR(50) = NULL + ,@LogInfo VARCHAR(MAX) = NULL +AS +----------------------------------------------------- + -- #101 - Mobile Changes , #361 - Multi-Lingual +----------------------------------------------------- +SET NOCOUNT ON; +SET XACT_ABORT ON; + +BEGIN TRY + DECLARE + @UserData VARCHAR(200) + ,@lastPwdChangedOn DATETIME + ,@forceChangePwd CHAR(1) + ,@pwdChangeDays VARCHAR(20) + ,@msg VARCHAR(2000) + ,@pwdChangeWarningDays VARCHAR(5) + ,@lastLoginDate DATETIME + + DECLARE @email VARCHAR(100) + ,@customerPwd VARCHAR(50) + ,@isActive CHAR(1) + ,@onlineUser CHAR(1) + ,@isLocked VARCHAR(1) + ,@ccountry VARCHAR(50) + ,@customerStatus CHAR(1) + ,@loginAttempt INT + ,@existingCustomer INT + + IF @flag = 'check-id' + BEGIN + IF EXISTS(SELECT FULLNAME FROM CUSTOMERMASTER (NOLOCK) WHERE IDNUMBER = @idNumber) OR + EXISTS(SELECT 'x' FROM dbo.CustomerMasterTemp AS CM(NOLOCK) WHERE IDNUMBER = @idNumber AND createdBy IS NOT NULL) + BEGIN + SELECT 1 ERRORCODE,'Already exists!' MSG,NULL + RETURN + END + + SELECT 0 ERRORCODE,'Success' MSG,NULL + RETURN + END + IF @flag = 'checkIp' + BEGIN + IF NOT EXISTS( SELECT COUNTRYNAME FROM COUNTRYMASTER WITH (NOLOCK) + WHERE ISNULL(allowOnlineCustomer,'N')='Y' AND upper(COUNTRYNAME)=upper(@checkCountry)) + BEGIN + SELECT 1 ERRORCODE,'NOT AVAILABLE' MSG,NULL + RETURN + END + ELSE + BEGIN + SELECT 0 ERRORCODE,'AVAILABLE' MSG,NULL + END + END + + IF @flag = 'l' + BEGIN + IF NOT EXISTS(SELECT 'x' FROM customerMaster WITH(NOLOCK) WHERE email=@customerEmail) + BEGIN + SELECT 1 errorCode, 'Login Failed - Invalid username or password!' msg, @customerEmail id + RETURN + END + SELECT @email=email, + @customerPwd=customerPassword, + @isActive=isactive, + @onlineUser=onlineuser, + @isLocked=isLocked, + @ccountry=country, + @customerStatus=customerStatus, + @lastLoginDate=lastLoginTs, + @loginAttempt = ISNULL(invalidAttemptCount, 0), + @existingCustomer= ISNULL(isexistingcustomer,0) + FROM customerMaster WITH (NOLOCK) + WHERE email=@customerEmail and ISNULL(onlineUser, 'N')='Y' + + SET @UserData ='User: '+ @customerEmail +' User Type:Online User' + DECLARE @attemptsCount INT, @InvalidReason VARCHAR(80), @InvalidMsg VARCHAR(100) + SELECT TOP 1 @attemptsCount = loginAttemptCount FROM passwordFormat WITH(NOLOCK) + + IF( @existingCustomer=1 and (@customerPwd IS NULL OR @customerPwd='')) + BEGIN + SELECT 3 errorCode, 'Login Failed. Please click forgot Password to set new password.' msg, @customerEmail id, @attemptsCount ac + SET @UserInfoDetail = 'Reason = Login fails, Invalid password.-:::-'+@UserInfoDetail + EXEC proc_applicationLogs + @flag='login', + @logType='Login fails', + @createdBy = @customerEmail, + @Reason='Not online User', + @UserData = @UserData, + @fieldValue = @UserInfoDetail, + @IP = @ipAddress + RETURN + END + + IF (ISNULL(@isLocked, 'N') IN ('B', 'Y')) OR ((@loginAttempt - @attemptsCount) = -1) + BEGIN + SET @UserInfoDetail = 'Reason = Too many wrong attempts .-:::-' + @UserInfoDetail + + SELECT 1 errorCode, 'Login Failed - Too many wrong attempts, please contact GME Support!' msg, @customerEmail id, @attemptsCount ac + EXEC proc_applicationLogs + @flag='login', + @logType='Login fails', + @createdBy = @customerEmail, + @Reason= 'Reason = Too many wrong attempts.', + @UserData = @UserData, + @fieldValue = @UserInfoDetail, + @IP = @ipAddress + RETURN + END + PRINT @customerPwd + + IF (@customerPwd <> dbo.FNAEncryptString(@customerPassword)) + BEGIN + + SET @UserInfoDetail = 'Reason = Incorrect password .-:::-' + @UserInfoDetail + + SET @loginAttempt = @loginAttempt + 1 + + UPDATE customerMaster SET invalidAttemptCount = @loginAttempt--, isLocked = CASE WHEN @loginAttempt > @attemptsCount THEN 'B' ELSE 'N' END + WHERE email = @customerEmail and ISNULL(onlineUser, 'N')='Y' + + SET @InvalidReason = CASE WHEN @loginAttempt > @attemptsCount THEN 'Number of invalid password attempts exceeded!' ELSE 'Invalid Password' END + SET @InvalidMsg = 'Login Failed - you have ' + CAST((@attemptsCount - @loginAttempt) AS VARCHAR) + ' Attempts Left' + + SELECT 1 errorCode, @InvalidMsg msg, @customerEmail id, @attemptsCount ac + EXEC proc_applicationLogs + @flag='login', + @logType='Login fails', + @createdBy = @customerEmail, + @Reason= @InvalidReason, + @UserData = @UserData, + @fieldValue = @UserInfoDetail, + @IP = @ipAddress + RETURN + END + + IF (ISNULL(@onlineUser, 'N') = 'N') + BEGIN + SELECT 2 errorCode, 'User is not an Online User' msg, @customerEmail id, @attemptsCount ac + SET @UserInfoDetail = 'Reason = Login fails, Invalid password.-:::-'+@UserInfoDetail + EXEC proc_applicationLogs + @flag='login', + @logType='Login fails', + @createdBy = @customerEmail, + @Reason='Not online User', + @UserData = @UserData, + @fieldValue = @UserInfoDetail, + @IP = @ipAddress + RETURN + END + + DECLARE @vPenny CHAR(1),@vCustomerId BIGINT + + --SELECT @vCustomerId=CM.customerId , @vPenny = CASE WHEN CM.createdDate < '2018-12-19 11:00:00' THEN 'N' WHEN ISNULL(CC.action,'REQ') = 'REQ' THEN 'Y' ELSE 'N' END + --from customerMaster CM (nolock) + --LEFT JOIN TblCustomerBankVerification CC (nolock) ON CM.customerId = CC.customerId + --WHERE CM.email = @customerEmail + + --IF @vPenny = 'Y' + --BEGIN + -- SELECT 1000 errorCode, 'User redirect to penny test verification' mes, @vCustomerId id + -- SET @UserInfoDetail = 'Reason = Login fails, User redirect to penny test verification.-:::-'+@UserInfoDetail + -- EXEC proc_applicationLogs + -- @flag='login', + -- @logType='Login fails', + -- @createdBy = @customerEmail, + -- @Reason='Penny test verification', + -- @UserData = @UserData, + -- @fieldValue = @UserInfoDetail, + -- @IP = @ipAddress + -- RETURN + --END + IF (ISNULL(@isActive, 'Y') = 'N') + BEGIN + SELECT 1 errorCode, 'Your account is Inactive. Please, contact GME Support Team.' msg, @customerEmail id + SET @UserInfoDetail = 'Reason = Login fails, Your account is Inactive. Please, contact your administrator.-:::-'+@UserInfoDetail + EXEC proc_applicationLogs + @flag='login', + @logType='Login fails', + @createdBy = @customerEmail, + @Reason='User is not active ', + @UserData = @UserData, + @fieldValue = @UserInfoDetail, + @IP = @ipAddress + RETURN + END + + --IF EXISTS (SELECT 'x' FROM customerMaster (NOLOCK) WHERE email=@customerEmail AND approvedBy IS NULL AND approvedDate IS NULL) + --BEGIN + -- SELECT 1 errorCode, 'Login Failed - Customer registration verification pending please visit nearest GME branch to get verified!' msg, @customerEmail id + -- RETURN + --END + + UPDATE customerMaster SET + sessionId=@sessionId + ,lastLoginTs = GETDATE() + ,invalidAttemptCount = 0 + WHERE email = @customerEmail and ISNULL(onlineUser, 'N')='Y' + + DECLARE @mobileNo VARCHAR(16) + + SET @mobileNo = REPLACE(@mobileNo,' ','') + SET @mobileNo = REPLACE(@mobileNo,'-','') + SET @mobileNo = REPLACE(@mobileNo,'+','') + SET @mobileNo = LEFT(@mobileNo,16) + + DECLARE @clientUseCode VARCHAR(10), @clientId VARCHAR(50), @clientSecret VARCHAR(50), @accessToken VARCHAR(400), @gmeBankCode VARCHAR(3), @gmeAccountNo VARCHAR(20) + + SELECT @clientUseCode = DBO.DECRYPTDB(clientUseCode), @clientId = DBO.DECRYPTDB(clientId), @clientSecret = DBO.DECRYPTDB(clientSecret) + , @accessToken = accessToken, @gmeAccountNo = accountNum, @gmeBankCode = bankCodeStd + FROM KFTC_GME_MASTER (NOLOCK) + + + SELECT + TOP 1 + 0 errorCode + ,'Login success.' msg + ,cu.customerId Id + ,username = cu.email + ,fullName = cu.fullName + ,country = cm.countryName + ,agent_branch_code=cu.branchId + ,agentcode=cu.agentId + ,date_format=NULL + ,limitPerTran=0 + ,GMT_value=NULL + ,currencyType=NULL + ,extra_rate_bank=NULL + ,cash_ledger_id=NULL + ,@attemptsCount [ac] + ,sessionTimeOutPeriod=NULL + ,lastLoginTs=GETDATE() + ,cm.countryId + ,[address] = cu.city +'-Provience,South Korea' + ,[address2]=cu.[address2] + ,homePhone=cu.homePhone + ,mobile=cu.mobile + ,cm.countryCode + ,utcTime=8 + ,mobile= @mobileNo + ,city=cu.city + ,postalCode=cu.postalCode + ,membershipId=membershipId + ,sdv.detailTitle idType + ,cu.idNumber + ,isForcedPwdChange = ISNULL(isForcedPwdChange,0) + ,customerStatus + ,cu.walletAccountNo + ,primaryBankName=CASE WHEN cu.customerType='11048' THEN 'Mutual savings bank(050)' ELSE 'Kwangju Bank (034)' END + ,nativeCountry = cm1.countryName + ,nativeCountryId = cm1.countryId + ,nativeCountryCode = cm1.countryCode + ,occupation = sd.detailTitle + ,idExpiryDate = CASE WHEN cu.idType='8008' THEN '2059-12-12' ELSE FORMAT(cu.idExpiryDate,'MM/dd/yyyy') END + ,birthDate = FORMAT(cu.dob,'MM/dd/yyyy') + ,accessToken = KFTC.accessToken + ,clientUseCode = @clientUseCode + ,clientId = @clientId + ,clientSecret = @clientSecret + ,gmeAccessToken = @accessToken + ,gmeBankCode = @gmeBankCode + ,gmeAccountNum = @gmeAccountNo + ,rewardPoints= DBO.FNA_GET_AVAILABLE_BALANCE_POINTS(cu.customerId) + ,IsEmailVerified = ISNULL(isEmailVerified,0) + ,cu.SelfieDoc + FROM customerMaster cu WITH(NOLOCK) + LEFT JOIN countryMaster cm WITH (NOLOCK) ON cm.countryId=cu.country + LEFT JOIN countryMaster cm1 with(nolock) on cm1.countryId = cu.nativeCountry + left join staticDataValue sdv with (nolock) on sdv.valueId=cu.idType + left join staticDataValue sd with(nolock) on sd.valueId = cu.occupation + LEFT JOIN dbo.vwBankLists vwbank WITH (NOLOCK) ON cu.bankName=vwbank.rowid + LEFT JOIN KFTC_CUSTOMER_MASTER KFTC(NOLOCK) ON KFTC.customerId = CU.customerId + WHERE cu.email= @customerEmail + and ISNULL(cu.onlineUser, 'N')='Y' + + + EXEC proc_applicationLogs + @flag='login', + @logType='Login', + @createdBy = @customerEmail, + @Reason='Login', + @UserData = @UserData, + @fieldValue = @UserInfoDetail, + @IP = @ipAddress + END + + ELSE IF @flag = 'loc' + BEGIN + UPDATE customerMaster SET + isLocked = 'Y' + WHERE email= @customerEmail and ISNULL(onlineUser, 'N')='Y' + INSERT INTO userLockHistory(userName, lockReason, createdBy, createdDate) + SELECT @customerEmail, @lockReason, 'system',GETDATE() + SELECT 0 errorCode, 'Your account has been locked. Please, contact your administrator.' mes, @customerEmail id + END + + ELSE IF @flag='availbal' + BEGIN + SELECT ISNULL(availableBalance, 0.00) AS availableBalance FROM dbo.customerMaster(nolock) + WHERE email=@customerEmail + + --SELECT 0 errorCode,ISNULL(a.clr_bal_amt, 0.00) AS availableBalance + --FROM dbo.customerMaster c(nolock) + --INNER JOIN FastMoneyPro_account.dbo.ac_master a(nolock) ON A.acct_num = c.walletAccountNo + --WHERE c.email = @customerEmail + END + ELSE IF @flag='checkpin' + BEGIN + DECLARE @TXN_PIN VARCHAR(30) + IF NOT EXISTS(SELECT 'X' FROM customerMaster WITH (NOLOCK) + WHERE username=@customerEmail and ISNULL(onlineUser, 'N')='Y') + BEGIN + SELECT @email=email, + @customerPwd=customerPassword, + @isActive=isactive, + @onlineUser=onlineuser, + @isLocked=isLocked, + @ccountry=country, + @customerStatus=customerStatus, + @lastLoginDate=lastLoginTs, + @loginAttempt = ISNULL(invalidAttemptPinCount, 0), + @TXN_PIN = txnPin + FROM customerMaster WITH (NOLOCK) + WHERE username=@customerEmail and ISNULL(onlineUser, 'N')='Y' + END + ELSE + BEGIN + SELECT @email=email, + @customerPwd=customerPassword, + @isActive=isactive, + @onlineUser=onlineuser, + @isLocked=isLocked, + @ccountry=country, + @customerStatus=customerStatus, + @lastLoginDate=lastLoginTs, + @loginAttempt = ISNULL(invalidAttemptPinCount, 0), + @TXN_PIN = txnPin + FROM customerMaster WITH (NOLOCK) + WHERE username=@customerEmail and ISNULL(onlineUser, 'N')='Y' + END + IF (ISNULL(@password, '') = ISNULL(@TXN_PIN, '-1')) + BEGIN + UPDATE customerMaster SET + invalidAttemptPinCount = 0 + WHERE username = @customerEmail and ISNULL(onlineUser, 'N')='Y' + + SELECT 0 errorCode, 'Success' msg, @customerEmail id + RETURN; + END + + + SELECT TOP 1 @attemptsCount = loginAttemptCount FROM passwordFormat WITH(NOLOCK) + + IF (ISNULL(@isLocked, 'N') IN ('B', 'Y')) OR ((@loginAttempt - @attemptsCount) = -1) + BEGIN + SELECT 18 errorCode, 'Too many wrong attempts, please contact JME Support!' mes, @customerEmail id + EXEC proc_applicationLogs + @flag='login', + @logType='Send Transaction', + @createdBy = @customerEmail, + @Reason= 'Reason = Too many wrong attempts sending transaaction.' + RETURN + END + + IF (ISNULL(@password, '') <> ISNULL(@TXN_PIN, '-1')) + BEGIN + SET @UserInfoDetail = 'Reason = Incorrect PIN .-:::-' + @UserInfoDetail + + SET @loginAttempt = @loginAttempt + 1 + + UPDATE customerMaster SET invalidAttemptPinCount = @loginAttempt, isLocked = CASE WHEN @loginAttempt > @attemptsCount THEN 'B' ELSE 'N' END + WHERE username = @customerEmail and ISNULL(onlineUser, 'N')='Y' + + SET @InvalidReason = CASE WHEN @loginAttempt > @attemptsCount THEN 'Number of invalid PIN attempts exceeded!' ELSE 'Invalid PIN' END + SET @InvalidMsg = 'Send txn Failed - Invalid PIN, you have ' + CAST((@attemptsCount - @loginAttempt) AS VARCHAR) + ' Attempts Left' + + SELECT 20 errorCode, @InvalidMsg mes, @customerEmail id + EXEC proc_applicationLogs + @flag='login', + @logType='Send Transaction', + @createdBy = @customerEmail, + @Reason= 'Reason = wrong transaction PIN.' + RETURN + END + END + ELSE IF @flag='checkpass' + BEGIN + IF NOT EXISTS(SELECT 'X' FROM customerMaster WITH (NOLOCK) + WHERE username=@customerEmail and ISNULL(onlineUser, 'N')='Y') + BEGIN + SELECT @email=email, + @customerPwd=customerPassword, + @isActive=isactive, + @onlineUser=onlineuser, + @isLocked=isLocked, + @ccountry=country, + @customerStatus=customerStatus, + @lastLoginDate=lastLoginTs, + @loginAttempt = ISNULL(invalidAttemptCount, 0), + @TXN_PIN = txnPin + FROM customerMaster WITH (NOLOCK) + WHERE username=@customerEmail and ISNULL(onlineUser, 'N')='Y' + END + ELSE + BEGIN + SELECT @email=email, + @customerPwd=customerPassword, + @isActive=isactive, + @onlineUser=onlineuser, + @isLocked=isLocked, + @ccountry=country, + @customerStatus=customerStatus, + @lastLoginDate=lastLoginTs, + @loginAttempt = ISNULL(invalidAttemptCount, 0), + @TXN_PIN = txnPin + FROM customerMaster WITH (NOLOCK) + WHERE username=@customerEmail and ISNULL(onlineUser, 'N')='Y' + END + IF (@customerPwd = dbo.FNAEncryptString(@password)) + BEGIN + UPDATE customerMaster SET + invalidAttemptCount = 0 + WHERE username = @customerEmail and ISNULL(onlineUser, 'N')='Y' + + SELECT 0 errorCode, 'Success' msg, @customerEmail id + RETURN; + END + + SELECT TOP 1 @attemptsCount = loginAttemptCount FROM passwordFormat WITH(NOLOCK) + + IF (ISNULL(@isLocked, 'N') IN ('B', 'Y')) OR ((@loginAttempt - @attemptsCount) = -1) + BEGIN + SELECT 9 errorCode, 'Too many wrong attempts, please contact GME Support!' mes, @customerEmail id + EXEC proc_applicationLogs + @flag='login', + @logType='Send Transaction', + @createdBy = @customerEmail, + @Reason= 'Reason = Too many wrong attempts sending transaaction.' + RETURN + END + + IF (@customerPwd <> dbo.FNAEncryptString(@password)) + BEGIN + SET @UserInfoDetail = 'Reason = Incorrect password .-:::-' + @UserInfoDetail + + SET @loginAttempt = @loginAttempt + 1 + + UPDATE customerMaster SET invalidAttemptCount = @loginAttempt, isLocked = CASE WHEN @loginAttempt > @attemptsCount THEN 'B' ELSE 'N' END + WHERE email = @customerEmail and ISNULL(onlineUser, 'N')='Y' + + SET @InvalidReason = CASE WHEN @loginAttempt > @attemptsCount THEN 'Number of invalid password attempts exceeded!' ELSE 'Invalid Password' END + SET @InvalidMsg = 'Login Failed - Invalid Password, you have ' + CAST((@attemptsCount - @loginAttempt) AS VARCHAR) + ' Attempts Left' + + SELECT 1 errorCode, @InvalidMsg mes, @customerEmail id + EXEC proc_applicationLogs + @flag='login', + @logType='Send Transaction', + @createdBy = @customerEmail, + @Reason= 'Reason = wrong transaction password.' + RETURN + END + END + +END TRY +BEGIN CATCH + IF @@TRANCOUNT > 0 + ROLLBACK TRANSACTION + DECLARE @errorMessage VARCHAR(MAX) + SET @errorMessage = ERROR_MESSAGE() + EXEC proc_errorHandler 1, @errorMessage,NULL +END CATCH + + + +GO + diff --git a/StoredProc/mobile_proc_customerMaster.sql b/StoredProc/mobile_proc_customerMaster.sql index b7085e0..7af6a4d 100644 Binary files a/StoredProc/mobile_proc_customerMaster.sql and b/StoredProc/mobile_proc_customerMaster.sql differ diff --git a/StoredProc/mobile_proc_userLogin.sql b/StoredProc/mobile_proc_userLogin.sql index 1c3b86e..3ea15b5 100644 Binary files a/StoredProc/mobile_proc_userLogin.sql and b/StoredProc/mobile_proc_userLogin.sql differ diff --git a/StoredProc/proc_get_exrate_master.sql b/StoredProc/proc_get_exrate_master.sql index d9961da..0395d49 100644 Binary files a/StoredProc/proc_get_exrate_master.sql and b/StoredProc/proc_get_exrate_master.sql differ diff --git a/StoredProc/proc_modifyTXN.sql b/StoredProc/proc_modifyTXN.sql index cb9246c..6c7c78a 100644 Binary files a/StoredProc/proc_modifyTXN.sql and b/StoredProc/proc_modifyTXN.sql differ diff --git a/StoredProc/proc_online_approve_Customer.sql b/StoredProc/proc_online_approve_Customer.sql index 62f2d29..288f077 100644 Binary files a/StoredProc/proc_online_approve_Customer.sql and b/StoredProc/proc_online_approve_Customer.sql differ diff --git a/StoredProc/proc_online_core_customerSetup.sql b/StoredProc/proc_online_core_customerSetup.sql index d6f6b8f..20df2d5 100644 Binary files a/StoredProc/proc_online_core_customerSetup.sql and b/StoredProc/proc_online_core_customerSetup.sql differ diff --git a/StoredProc/proc_online_customer_login.sql b/StoredProc/proc_online_customer_login.sql index 6b1ff8e..4f4a931 100644 Binary files a/StoredProc/proc_online_customer_login.sql and b/StoredProc/proc_online_customer_login.sql differ