예제 #1
0
        public IActionResult Login(US_USER _obj, string nexturl)
        {
            try
            {
                //FormsAuthentication.SetAuthCookie(user.LOGIN_ID.ToUpper().Trim(), false);
                if (_obj.LOGIN_ID == null || _obj.PASSWORD == null)
                {
                    TempData["message"] = "Enter Valid Information !!!";
                    return(View(_obj));
                }
                string userId   = _obj.LOGIN_ID.ToLower().Trim();
                string userPass = TextEncryption.EncryptionWithSh(_obj.PASSWORD);

                US_USER _data = _unitOfWork.US_USER.GetFirstOrDefult(x => x.LOGIN_ID.ToLower() == userId && x.PASSWORD == userPass && x.IS_ACTIVE == true);
                if (_data == null)
                {
                    TempData["message"] = "Enter Valid Information !!!";
                    return(View(_obj));
                }
                else
                {
                    HttpContext.Session.SetInt32("sessionID", _data.ID);
                    HttpContext.Session.SetString("sessionLOGIN_ID", _data.LOGIN_ID);
                    //LeaderBoard();
                    Index();
                }
            }
            catch (Exception ex)
            {
                TempData["message"] = ex.Message.ToString();
                return(View(_obj));
            }

            return(RedirectToLocal(nexturl));
        }
예제 #2
0
        public void Default(string alg)
        {
            CodeActivity <IEncryption> handler = null;

            switch (alg)
            {
            case nameof(AesAlgorithmEncryption):
                handler = new AesAlgorithmEncryption();
                break;

            case nameof(DESAlgorithmEncryption):
                handler = new DESAlgorithmEncryption();
                break;

            case nameof(RC2AlgorithmEncryption):
                handler = new RC2AlgorithmEncryption();
                break;

            case nameof(RijndaelAlgorithmEncryption):
                handler = new RijndaelAlgorithmEncryption();
                break;

            case nameof(TripleDESAlgorithmEncryption):
                handler = new TripleDESAlgorithmEncryption();
                break;

#if NET5_0
            case nameof(AesGcmAlgorithmEncryption):
                handler = new AesGcmAlgorithmEncryption();
                break;
#endif
            }

            var text         = Guid.NewGuid().ToString();
            var secureString = new NetworkCredential("", CryptoKey).SecurePassword;

            var activity = new TextEncryption()
            {
                Algorithm = new ActivityFunc <IEncryption>()
                {
                    Handler = handler
                },
                Key = new InArgument <SecureString>(_ => secureString)
            };

            var encrypted = WorkflowTester.CompileAndInvoke(activity, GetArgs(text));
            Assert.IsNotNull(encrypted);
            Assert.AreNotEqual(text, encrypted);

            activity.Action = Core.Enums.CryptoActions.Decrypt;
            var decrypted = WorkflowTester.CompileAndInvoke(activity, GetArgs(encrypted));
            Assert.IsNotNull(decrypted);
            Assert.AreNotEqual(encrypted, decrypted);
            Assert.AreEqual(text, decrypted);
        }
예제 #3
0
        public IActionResult ManageUser(US_USER _obj)
        {
            bool   success_upload = false;
            string file_name      = string.Empty;

            try
            {
                if (_obj.PROFILE_IMAGE_FILE != null)
                {
                    string fname = Path.GetFileName(_obj.PROFILE_IMAGE_FILE.FileName);
                    file_name = Path.GetFileNameWithoutExtension(fname) + "_"
                                + Guid.NewGuid().ToString().Substring(0, 4) + Path.GetExtension(fname);

                    var uploads  = Path.Combine(_hostEnvironment.WebRootPath, "uploads\\userprofiles");
                    var filePath = Path.Combine(uploads, file_name);
                    _obj.PROFILE_IMAGE_FILE.CopyTo(new FileStream(filePath, FileMode.Create));
                }
                success_upload = true;
            }
            catch { success_upload = false; }


            if (ModelState.IsValid)
            {
                if (success_upload)
                {
                    _obj.PROFILE_IMAGE = file_name;
                }

                if (_obj.ID == 0)
                {
                    _obj.ID        = _unitOfWork.US_USER.GetAll().Max(x => x.ID) + 1;
                    _obj.PASSWORD  = TextEncryption.EncryptionWithSh(_obj.PASSWORD);
                    _obj.IS_ACTIVE = true;
                    _unitOfWork.US_USER.Add(_obj);
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(_obj.PASSWORD))
                    {
                        _obj.PASSWORD = TextEncryption.EncryptionWithSh(_obj.PASSWORD);
                    }
                    _unitOfWork.US_USER.Update(_obj);
                }
                _unitOfWork.Save();
                TempData["msg"] = SweetMsg.SaveSuccess();
                return(RedirectToAction(nameof(ManageUser)));
            }
            TempData["msg"] = SweetMsg.SaveErrorOK();
            DropDownFor_ManageUser();
            return(View(_obj));
        }
예제 #4
0
 private void US_USER_Ins()
 {
     #region US_USER_Ins
     List <US_USER> _d = new List <US_USER>
     {
         new US_USER {
             ID = 1, LOGIN_ID = "admin", PASSWORD = TextEncryption.EncryptionWithSh("a"), USER_NAME = "Administrator", MOBILE_NO = "01000000000", EMAIL_ID = "*****@*****.**", DATE_OF_BIRTH = DateTime.Now.Date, PROFILE_IMAGE = "-", GENDER_ID = 1, RELIGION_ID = 1, BLOOD_GROUP_ID = 1, MARITAIL_STATUS_ID = 1, TYPE_ID = 1
         }
     };
     _unitOfWork.US_USER.AddRange(_d);
     _unitOfWork.Save();
     #endregion
 }
        private void encryptMessage()
        {
            var encrypter = new TextEncryption(this.MessageText, this.HeaderPixel.RotShift);

            this.MessageText = encrypter.EncryptText();
        }
예제 #6
0
        public KeyValuePair <bool, string> UpdateUser(Employee Employee)
        {
            KeyValuePair <HttpStatusCode, string> result = this.DotNetNukeApi.UpdateUser(Employee.UserName, TextEncryption.Decypt(Employee.StoredPassword), Employee.Email, Employee.FirstName, Employee.LastName, this.Database);

            if (result.Key != HttpStatusCode.OK)
            {
                return(new KeyValuePair <bool, string>(false, string.Format(_userNotUpdated, result.Value)));
            }
            else
            {
                return(new KeyValuePair <bool, string>(false, string.Format(_userUpdated, result.Value)));
            }
        }