Ejemplo n.º 1
0
 public async Task <LoginTokenDataModel> CheckUserCredentialsAsync(CredentialModel credentialModel)
 {
     try
     {
         LoginTokenDataModel loginTokenDataModel = new LoginTokenDataModel();
         if (credentialModel != null)
         {
             List <KeyValuePair <string, object> > param = new List <KeyValuePair <string, object> >()
             {
                 new KeyValuePair <string, object>("@username", credentialModel.UserName),
                 new KeyValuePair <string, object>("@password", EncryptManager.GetHashString(credentialModel.Password ?? string.Empty))
             };
             var data = DataExecutor.ExecuteDataTable(UtilityConstant.Procedures.Usp_CheckUserCredential, param);
             if (data != null && data.Columns.Count > 1)
             {
                 LoginTokenModel loginTokenModel = new LoginTokenModel()
                 {
                     ExpireTime = DateTime.Now.AddMinutes(30),
                     Message    = string.Empty,
                     SecureId   = Guid.NewGuid().ToString(),
                     UserData   = data
                 };
                 loginTokenDataModel.UserData = data;
                 loginTokenDataModel.Message  = "ValidUser";
                 loginTokenDataModel.Token    = EncryptManager.Encrypt(JsonConvert.SerializeObject(loginTokenModel), AppSetting.GetAppSettingsData(UtilityConstant.AppConfigConstant.AppVariable, UtilityConstant.AppConfigConstant.SaltKey, string.Empty));
             }
             else
             {
                 loginTokenDataModel.Message = data.Rows[0][0].ToString();
             }
         }
         return(loginTokenDataModel);
     }
     catch (Exception ex)
     {
         throw;
     }
 }