public dynamic authenticatedUserDetails(userAuthenticationModel obj) { dynamic objdata = new ExpandoObject(); //string json = JsonConvert.SerializeObject(obj); //string iv = CryptLib.GenerateRandomIV(16); //string key = CryptLib.getHashSha256(obj.DeptCode, 31); //string encrypttext = new CryptLib().encrypt(json, key, iv); try { string decrypted_text = string.Empty; if (string.IsNullOrEmpty(obj.ENCRYPTED_DATA) || string.IsNullOrEmpty(obj.KEY) || string.IsNullOrEmpty(obj.IV)) { objdata.status = 400; objdata.result = null; } else { decrypted_text = EncryptDecryptAlgoritham.DecryptStringAES(obj.ENCRYPTED_DATA, obj.KEY, obj.IV); //new CryptLib().decrypt(obj.ENCRYPTED_DATA, obj.KEY, obj.IV); objdata.status = 200; objdata.result = decrypted_text; } } catch (Exception ex) { objdata.status = 500; objdata.result = ex; } return(objdata); }
public DataTable autheticationProcedure(userAuthenticationModel obj) { try { using (OracleConnection con = new OracleConnection(oradb)) { using (OracleCommand cmd = new OracleCommand()) { cmd.Connection = con; cmd.InitialLONGFetchSize = 1000; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "gsws_sp_auth_otp_log"; cmd.Parameters.Add("ftype", OracleDbType.Varchar2).Value = obj.TYPE; cmd.Parameters.Add("fmobile_number", OracleDbType.Varchar2).Value = obj.MOBILE_NUMBER; cmd.Parameters.Add("fotp", OracleDbType.Varchar2).Value = obj.OTP; cmd.Parameters.Add("fgsws_id", OracleDbType.Varchar2).Value = obj.PS_ID; cmd.Parameters.Add("femp_id", OracleDbType.Varchar2).Value = obj.EMP_ID; cmd.Parameters.Add("P_CUR", OracleDbType.RefCursor).Direction = ParameterDirection.Output; OracleDataAdapter oda = new OracleDataAdapter(cmd); DataTable data = new DataTable(); oda.Fill(data); return(data); } } } catch (Exception ex) { throw ex; } }
public IHttpActionResult authenticatedUserDetails(dynamic data) { string serialized_data = JsonConvert.SerializeObject(data); userAuthenticationModel rootobj = JsonConvert.DeserializeObject <userAuthenticationModel>(serialized_data); return(Ok(_Hel.authenticatedUserDetails(rootobj))); }
public dynamic authenticateUserSendOTP(userAuthenticationModel obj) { dynamic objdata = new ExpandoObject(); try { obj.TYPE = "2"; DataTable dt = autheticationProcedure(obj); if (dt != null && dt.Rows.Count > 0) { bool test = false; int OTP = 0; if (dt.Rows[0]["TEST"].ToString() == "1") { test = true; OTP = 123456; } else { Random obj_random = new Random(); OTP = obj_random.Next(111111, 999999); } if (send_otp_using_mobile_number(dt.Rows[0]["MOBILE_NUMBER"].ToString(), OTP, "0", obj.PS_ID, obj.EMP_ID, test)) { objdata.status = 200; objdata.result = "OTP Successfully sent to registered moblie number"; } else { objdata.status = 400; objdata.result = "OTP Sending Failed,Please try again..."; } } else { objdata.status = 400; objdata.result = "No Mobile Number found to send OTP Please contact administrator"; } } catch (Exception ex) { objdata.status = 500; objdata.result = ex.Message.ToString(); } return(objdata); }
public dynamic authenticateUserVerifyOTP(userAuthenticationModel obj) { dynamic objdata = new ExpandoObject(); try { obj.TYPE = "1"; DataTable dt = autheticationProcedure(obj); if (dt != null && dt.Rows.Count > 0) { try { con.Open(); OracleCommand cmd = con.CreateCommand(); cmd.CommandText = @"UPDATE GSWS_AUTH_OTP_LOG SET OTP_TYPE=1 where GSWS_ID=:GSWS_ID and EMP_ID=:EMP_ID"; cmd.Parameters.Add(":GSWS_ID", OracleDbType.Varchar2).Value = obj.PS_ID; cmd.Parameters.Add(":EMP_ID", OracleDbType.Varchar2).Value = obj.EMP_ID; cmd.ExecuteNonQuery(); } catch (Exception ex) { } objdata.status = 200; objdata.result = "OTP Verified Successfully"; } else { objdata.status = 400; objdata.result = "Invalid OTP, Please Enter Valid OTP"; } } catch (Exception ex) { objdata.status = 500; objdata.result = ex.Message.ToString(); } return(objdata); }