Ejemplo n.º 1
0
        /// <summary>
        /// Displays the user profile.
        /// </summary>
        /// <param name="userId">The userId.</param>
        /// <returns></returns>
        public UserProfileBO DisplayUserProfile(int userId)
        {
            UserProfileBO userProfile = new UserProfileBO();
            UserMaster    user        = UserRepository.DisplayUserProfile(userId);
            List <UserWeddingSubscriptionBO> userWeddingSubscriptions = new List <UserWeddingSubscriptionBO>();
            AddressMasterBO address = new AddressMasterBO();

            ObjectMapper.Map(SystemRepository.GetAddressDetailsByType((int)AspectEnums.AddressOwnerType.User, userId), address);

            ObjectMapper.Map(user, userProfile);
            // userProfile.UserWeddingSubscriptions = userWeddingSubscriptions;
            userProfile.Address = address;
            RoleMaster role = user.UserRoles.Where(k => !k.isDeleted).ToList().Count > 0 ? user.UserRoles.Where(k => !k.isDeleted).ToList()[0].RoleMaster : null;

            userProfile.RoleID     = role != null ? role.RoleID : 0;
            userProfile.userRoleID = user.UserRoles.Where(k => !k.isDeleted).FirstOrDefault().UserRoleID;

            if (!String.IsNullOrEmpty(userProfile.ImagePath))
            {
                userProfile.ImagePath = userProfile.ImagePath; // AppUtil.GetServerMobileImages(userProfile.ImagePath, AspectEnums.ImageFileTypes.User);
            }
            else
            {
                userProfile.ImagePath = "~/content/images/users/avatar.png";
            }
            userProfile.IsAdmin   = UserRepository.IsAdminRole(Convert.ToInt32(userProfile.RoleID));
            userProfile.Mobile    = EncryptionEngine.DecryptString(userProfile.Mobile);
            userProfile.Phone     = EncryptionEngine.DecryptString(userProfile.Phone);
            userProfile.Email     = EncryptionEngine.DecryptString(userProfile.Email);
            userProfile.LoginName = EncryptionEngine.DecryptString(userProfile.LoginName);
            return(userProfile);
        }
Ejemplo n.º 2
0
        public JsonResponse <string> DecryptString(string str)
        {
            JsonResponse <string> result = new JsonResponse <string>();

            result.SingleResult = EncryptionEngine.DecryptString(str);
            return(result);
        }
Ejemplo n.º 3
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            if (!EncryptionEngine.IsCertExist(CertName, CertPath))
            {
                EncryptionEngine.CreatePfx(CertName, CertPath, password);
            }

            await Host.CreateDefaultBuilder()
            .UseConsoleLifetime()
            .ConfigureWebHostDefaults(builder =>
            {
                builder.UseKestrel(serverOptions =>
                {
                    serverOptions.Listen(ipAddress, sslPort,
                                         listenOptions =>
                    {
                        listenOptions
                        .UseHttps(CertPath + CertName + ".pfx", password)
                        .Protocols = HttpProtocols.Http2;
                    });
                    serverOptions.Listen(ipAddress, insecPort);
                })
                .UseStartup <GrpcServerStartup>();
            })
            .Build()
            .StartAsync(stoppingToken);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Change password of User
        /// </summary>
        /// <param name="GUID"> uniqe string </param>
        /// <param name="Password">password entered by user</param>
        /// <returns></returns>
        public bool ChangePassword(string GUID, string Password)
        {
            int       OTPExirationHrs = Convert.ToInt32(AppUtil.GetAppSettings(AspectEnums.ConfigKeys.OTPExirationHrs));
            DateTime  StartTime       = DateTime.Now.Subtract(new TimeSpan(OTPExirationHrs, 0, 0));
            DateTime  EndTime         = DateTime.Now;
            OTPMaster objOTP          = AccuitAdminDbContext.OTPMasters.FirstOrDefault(k => k.CreatedDate >= StartTime && k.CreatedDate <= EndTime && k.GUID == GUID);

            if (objOTP != null)
            {
                UserMaster user = AccuitAdminDbContext.UserMasters.FirstOrDefault(k => k.UserID == objOTP.UserID && !k.isDeleted);
                user.Password      = EncryptionEngine.EncryptString(Password);
                user.AccountStatus = (int)AspectEnums.UserLoginStatus.Active;
                user.ModifiedDate  = DateTime.Now;
                user.ModifiedBy    = objOTP.UserID;
                AccuitAdminDbContext.Entry <UserMaster>(user).State = System.Data.Entity.EntityState.Modified;
                //Delete all previous OTPs
                foreach (var o in AccuitAdminDbContext.OTPMasters.Where(k => k.UserID == user.UserID))
                {
                    AccuitAdminDbContext.OTPMasters.Remove(o);
                }
                return(AccuitAdminDbContext.SaveChanges() > 0);
            }
            else
            {
                return(false);
            }
        }
        public async Task <UserMasterDto> GetUserByEmailAsync(string email)
        {
            email = EncryptionEngine.EncryptString(email);
            var user = await _userRepository.GetUserByEmailAsync(email);

            return(_mapper.Map <UserMaster, UserMasterDto>(user));
        }
        public async Task <UserMasterDto> AuthenticateUser(string userName, string password)
        {
            userName = EncryptionEngine.EncryptString(userName);
            password = EncryptionEngine.EncryptString(password);
            var user = await _userRepository.AuthenticateUser(userName, password);

            return(_mapper.Map <UserMaster, UserMasterDto>(user));
        }
Ejemplo n.º 7
0
        public void TestMD5Encryption()
        {
            const string inputText = "konfdbencryption";
            var          engine    = EncryptionEngine.Get <MD5EncryptionEngine>();

            var actual = engine.Encrypt(inputText, null, null);

            Assert.AreEqual("25C58E164132538B20FC4866933DF126", actual);
        }
Ejemplo n.º 8
0
        public void TestSHAEncryption()
        {
            const string inputText = "konfdbencryption";
            var          engine    = EncryptionEngine.Get <SHA256Encryption>();

            var actual = engine.Encrypt(inputText, null, null);

            Assert.AreEqual("A4681013792D283BC472487C66449C53A30D4E9A3783952F1CF511F5E40C273A", actual);
        }
Ejemplo n.º 9
0
 public static byte[] Encrypt(string plainText)
 {
     byte[] cipherText;
     using (EncryptionEngine cipher = EncryptionEngine.GetInstance())
     {
         cipherText = cipher.Encrypt(plainText);
     }
     return(cipherText);
 }
Ejemplo n.º 10
0
 public static byte[] SecureHash(string plainText)
 {
     byte[] hash;
     using (EncryptionEngine cipher = EncryptionEngine.GetInstance())
     {
         hash = cipher.ComputeSecureHash(plainText);
     }
     return(hash);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Method to return user for an employee code
        /// </summary>
        /// <param name="loginName">cemployee Code</param>
        /// <returns>returns user</returns>
        public UserProfileBO GetUserByName(string loginName)
        {
            UserProfileBO userDetail = new UserProfileBO();

            ObjectMapper.Map(UserRepository.GetUserByName(loginName), userDetail);
            userDetail.Email  = EncryptionEngine.DecryptString(userDetail.Email);
            userDetail.Mobile = EncryptionEngine.DecryptString(userDetail.Mobile);
            return(userDetail);
        }
Ejemplo n.º 12
0
 public static byte[] DecryptAndHash(byte[] cipherText)
 {
     byte[] hash;
     using (EncryptionEngine cipher = EncryptionEngine.GetInstance())
     {
         hash = cipher.ComputeSecureHash(cipher.Decrypt(cipherText));
     }
     return(hash);
 }
Ejemplo n.º 13
0
        public List <UserMasterDTO> GetUsersByStatus(int status)
        {
            var result = UserRepository.GetUsersByStatus(status);

            foreach (var user in result)
            {
                user.Email = EncryptionEngine.DecryptString(user.Email);
            }
            return(mapper.Map <List <UserMasterDTO> >(result));
        }
Ejemplo n.º 14
0
        public static string Decrypt(byte[] cipherText)
        {
            string plainText;

            using (EncryptionEngine cipher = EncryptionEngine.GetInstance())
            {
                plainText = cipher.Decrypt(cipherText);
            }
            return(plainText);
        }
 public void Mapping(Profile profile)
 {
     profile.CreateMap <UserMaster, UserMasterDto>()
     .ForMember(d => d.Email, opt => opt.MapFrom(s => EncryptionEngine.DecryptString(s.Email)))
     .ForMember(d => d.UserName, opt => opt.MapFrom(s => EncryptionEngine.DecryptString(s.UserName)))
     .ForMember(d => d.Password, opt => opt.MapFrom(s => EncryptionEngine.DecryptString(s.Password)));
     profile.CreateMap <UserMasterDto, UserMaster>()
     .ForMember(d => d.Email, opt => opt.MapFrom(s => EncryptionEngine.EncryptString(s.Email)))
     .ForMember(d => d.UserName, opt => opt.MapFrom(s => EncryptionEngine.EncryptString(s.UserName)))
     .ForMember(d => d.Password, opt => opt.MapFrom(s => EncryptionEngine.EncryptString(s.Password)));
 }
Ejemplo n.º 16
0
        public bool UpdatePassword(int UserID, string Password)
        {
            UserMaster user = AccuitAdminDbContext.UserMasters.FirstOrDefault(k => k.UserID == UserID && !k.isDeleted);

            user.Password      = EncryptionEngine.EncryptString(Password);
            user.AccountStatus = (int)AspectEnums.UserLoginStatus.Active;
            user.ModifiedDate  = DateTime.Now;
            user.ModifiedBy    = UserID;
            AccuitAdminDbContext.Entry <UserMaster>(user).State = System.Data.Entity.EntityState.Modified;
            //Delete all previous OTPs
            return(AccuitAdminDbContext.SaveChanges() > 0);
        }
Ejemplo n.º 17
0
        public int SubmitNewEmployee(UserMasterBO model, string sessionID)
        {
            UserMaster userMaster = new UserMaster();

            model.Mobile    = EncryptionEngine.EncryptString(model.Mobile);
            model.Phone     = EncryptionEngine.EncryptString(model.Phone);
            model.Email     = EncryptionEngine.EncryptString(model.Email);
            model.LoginName = EncryptionEngine.EncryptString(model.LoginName);
            model.Password  = EncryptionEngine.EncryptString(model.Password);
            ObjectMapper.Map(model, userMaster);
            return(UserRepository.SubmitNewEmployee(userMaster, sessionID));
        }
Ejemplo n.º 18
0
        public void TestRSAEncryption()
        {
            const string             inputText = "konfdbencryption";
            RSACryptoServiceProvider csp       = new RSACryptoServiceProvider();
            var engine = EncryptionEngine.Get <RSAEncryptionEngine>();

            var parameters = new Dictionary <string, object> {
                { "privatekey", csp }
            };
            var decryptedValue = engine.Encrypt(inputText, null, parameters);
            var actual         = engine.Decrypt(decryptedValue, null, parameters);

            Assert.AreEqual(inputText, actual);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// return Partner Details Based on UserID and partnetID
        /// </summary>
        /// <param name="userid">User Id</param>
        /// <returns>return Partner Details  Based on  to userID and partnerID</returns>
        public PartnerDetailsBO DisplayPartnerDetails(long userID, long PartnerID, string shipToCode)
        {
            PartnerDetailsBO partnerDetails = new PartnerDetailsBO();
            var partner = StoreRepository.DisplayPartnerDetails(userID, PartnerID, shipToCode);

            ObjectMapper.Map(partner, partnerDetails);
            partnerDetails.PartnerMobileNo      = EncryptionEngine.DecryptString(partner.MobileNo);
            partnerDetails.PartnerEmailID       = EncryptionEngine.DecryptString(partner.EmailID);
            partnerDetails.PartnerContactPerson = partner.ContactPerson;
            partnerDetails.AVMTDPurchase        = partner.AVMTDPurchase;
            partnerDetails.AVMTDSale            = partner.AVMTDSale;
            partnerDetails.HAMTDPurchase        = partner.HAMTDPurchase;
            partnerDetails.HAMTDSale            = partner.HAMTDSale;
            partnerDetails.ACMTDPurchase        = partner.ACMTDPurchase;
            partnerDetails.ACMTDSale            = partner.ACMTDSale;
            return(partnerDetails);
        }
Ejemplo n.º 20
0
        ///// <summary>
        ///// Displays the store profile.
        ///// </summary>
        ///// <param name="storeID">The store identifier.</param>
        ///// <returns></returns>
        //public StoreBO DisplayStoreProfile(int storeID, long userID)
        //{
        //    StoreBO store = new StoreBO();
        //    ObjectMapper.Map(StoreRepository.DisplayStoreProfile(storeID, userID), store);
        //    if (!String.IsNullOrEmpty(store.PictureFileName))
        //    {
        //        store.PictureFileName = AppUtil.GetServerMobileImages(store.PictureFileName, AspectEnums.ImageFileTypes.Store);
        //    }
        //    if (store.GeoTagCount > 0)
        //    {
        //        string configGeoCount = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.GeoTagCountThreshold);
        //        if (!String.IsNullOrEmpty(configGeoCount) && store.GeoTagCount >= Convert.ToInt32(configGeoCount))
        //        {
        //            //store.IsGeoTagRequired = false;//Commented for enable geo tag required
        //        }
        //        store.IsGeoTagRequired = true;//Commented for enable geo tag required
        //    }
        //    store.MobileNo = EncryptionEngine.DecryptString(store.MobileNo);
        //    store.EmailID = EncryptionEngine.DecryptString(store.EmailID);
        //    return store;
        //}


        /// <summary>
        /// Displays the store profile.
        /// </summary>
        /// <param name="storeID">The store identifier.</param>
        /// <returns></returns>
        public List <StoreDTO> DisplayStoreProfile(int?storeID, long userID)
        {
            List <StoreDTO> userStores = new List <StoreDTO>();

            ObjectMapper.Map(StoreRepository.DisplayStoreProfile(storeID, userID), userStores);
            foreach (var item in userStores)
            {
                item.MobileNo = EncryptionEngine.DecryptString(item.MobileNo);
                item.EmailID  = EncryptionEngine.DecryptString(item.EmailID);
                if (!String.IsNullOrEmpty(item.PictureFileName))
                {
                    item.PictureFileName = AppUtil.GetServerMobileImages(item.PictureFileName, AspectEnums.ImageFileTypes.Store);
                }
            }

            return(userStores);
        }
Ejemplo n.º 21
0
        public ActionResult Register(string identifier)
        {
            UserMasterBO user = new UserMasterBO();

            identifier = identifier.Replace(' ', '+'); // Decoding URL into actual encrypted string.
            try
            {
                if (identifier != null)
                {
                    ViewBag.IsRegistered = true;

                    string decrypt = EncryptionEngine.Decrypt(identifier);
                    user.UserID          = Convert.ToInt32(decrypt.Split(',')[0]);
                    user.FirstName       = decrypt.Split(',')[1].ToString();
                    user.LastName        = decrypt.Split(',')[2].ToString();
                    user.LoginName       = decrypt.Split(',')[3].ToString();
                    ViewBag.TemplateName = decrypt.Split(',')[4].ToString();
                    var status = UserBusinessInstance.GetUserByLoginName(user.LoginName).AccountStatus;
                    if (status == (int)AspectEnums.UserAccountStatus.Pending)
                    {
                        return(View(user));
                    }
                    else
                    {
                        ViewBag.Message   = "User already exist. Please login in with your email address.";
                        ViewBag.IsSuccess = false;
                        ViewBag.ShowPopup = true;
                        return(View());
                    }
                }
                else
                {
                    ViewBag.Message   = "Invalid registration url. Contact administrator.";
                    ViewBag.IsSuccess = false;
                    ViewBag.ShowPopup = true;
                    return(View());
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message   = "Something went wrong. Contact administrator.";
                ViewBag.IsSuccess = false;
                ViewBag.ShowPopup = true;
                return(View());
            }
        }
Ejemplo n.º 22
0
        //public bool DeleteUserAttendence(long userID, DateTime selectedDate)
        //{
        //    return UserRepository.DeleteUserAttendence(userID, selectedDate);
        //}
        //#endregion



        ///// <summary>
        ///// Method to return user list for a company
        ///// </summary>
        ///// <param name="companyID">company primary ID</param>
        ///// <returns>returns user list</returns>
        //public IList<UserBO> GetUsers(int companyID)
        //{
        //    List<UserBO> users = new List<UserBO>();
        //    ObjectMapper.Map(UserRepository.GetUsers(companyID), users);
        //    return users;
        //}

        ///// <summary>
        ///// Method to Reset IsofflineStatus
        ///// </summary>
        ///// <param name="userID">userID</param>
        ///// <returns>returns user</returns>

        //public bool ManageUserProfile(long userID, bool currentStatus)
        //{
        //    return UserRepository.ManageUserProfile(userID, currentStatus);
        //}

        ///// <summary>
        ///// Method to return device list for a company
        ///// </summary>
        ///// <param name="companyID">company primary ID</param>
        ///// <returns>returns user list</returns>
        //public IList<UserDeviceBO> GetUserDevices(long userID)
        //{
        //    List<UserDeviceBO> devices = new List<UserDeviceBO>();
        //    ObjectMapper.Map(UserRepository.GetUserDevices(userID), devices);
        //    return devices;
        //}

        ///// <summary>
        ///// Method to save imei number for an user
        ///// </summary>
        ///// <param name="userID">user ID</param>
        ///// <param name="imeiNumber">imei number</param>
        ///// <returns>returns boolean status</returns>
        //public int SaveDeviceIMEI(long userID, string imeiNumber, long createdBy)
        //{
        //    return UserRepository.SaveDeviceIMEI(userID, imeiNumber, createdBy);
        //}

        ///// <summary>
        ///// Method to delete imei number from database
        ///// </summary>
        ///// <param name="imeiNumber">imei number</param>
        ///// <param name="modifiedBy">modified by</param>
        ///// <param name="userID">user id</param>
        ///// <returns>returns boolean status</returns>
        //public bool DeleteDeviceIMEI(string imeiNumber, long modifiedBy, long userID)
        //{
        //    return UserRepository.DeleteDeviceIMEI(imeiNumber, modifiedBy, userID);
        //}

        ///// <summary>
        ///// Method to check whether valid device user
        ///// </summary>
        ///// <param name="imeiNumber">device imei number</param>
        ///// <returns>returns boolean status</returns>
        //public bool IsValidIMEINumber(string imeiNumber)
        //{
        //    return UserRepository.IsValidIMEINumber(imeiNumber);
        //}

        ///// <summary>
        ///// Method to get user details on the basis of imei number
        ///// </summary>
        ///// <param name="imeiNumber">device imei number</param>
        ///// <returns>returns boolean status</returns>
        //public UserProfileBO GetUserDetailsByIMEINumber(string imeiNumber)
        //{
        //    UserProfileBO userProfile = new UserProfileBO();
        //    ObjectMapper.Map(UserRepository.GetUserDetailsByIMEINumber(imeiNumber), userProfile);
        //    return userProfile;
        //}

        ///// <summary>
        ///// Method to update android registration id of user profile
        ///// </summary>
        ///// <param name="registrationId">registration id</param>
        ///// <param name="userID">user ID</param>
        ///// <returns>returns boolean status</returns>
        //public bool UpdateAndroidRegistrationId(string registrationId, long userID)
        //{
        //    return UserRepository.UpdateAndroidRegistrationId(registrationId, userID);
        //}

        /// <summary>
        /// Method to reset user's password
        /// </summary>
        /// <param name="employeeCode">employee code</param>
        /// <returns>returns boolean status</returns>
        public bool ResetUserPassword(string employeeCode)
        {
            bool       isReset     = false;
            UserMaster userDetails = UserRepository.GetUserByName(employeeCode);

            if (userDetails != null)
            {
                string password          = DateTime.Now.ToString().GetHashCode().ToString("x");
                string encryptedPassword = EncryptionEngine.EncryptString(password);
                isReset = UserRepository.ResetWebUserPassword(userDetails.UserID, encryptedPassword);
                if (isReset && !String.IsNullOrEmpty(EncryptionEngine.DecryptString(userDetails.Email)))
                {
                    SendResetPasswordEmail(EncryptionEngine.DecryptString(userDetails.Email), String.Format("{0} {1}", userDetails.FirstName, userDetails.LastName).Trim(), password);
                    isReset = true;
                }
            }
            return(isReset);
        }
Ejemplo n.º 23
0
        ///// <summary>
        ///// The product groups
        ///// </summary>
        //List<ProductGroupBO> productGroups = new List<ProductGroupBO>();

        ///// <summary>
        ///// Get list of User Master
        ///// </summary>
        ///// <returns></returns>
        //public IEnumerable<UserProfileBO> GetUsersMaster()
        //{
        //    List<UserProfileBO> GetUsersMaster = new List<UserProfileBO>();
        //    ObjectMapper.Map(UserRepository.GetUsersMaster(), GetUsersMaster);
        //    return GetUsersMaster;
        //}

        /// <summary>
        /// Updates the user profile.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="mobile">The mobile.</param>
        /// <param name="address">The address.</param>
        /// <param name="emailId">The email identifier.</param>
        /// <returns></returns>
        public bool UpdateUserProfile(UserProfileBO userProfile)
        {
            bool isSuccess = false;
            //UserProfileBO user = new UserProfileBO();
            UserMaster userMaster = new UserMaster();

            userProfile.Mobile = EncryptionEngine.EncryptString(userProfile.Mobile);
            userProfile.Phone  = EncryptionEngine.EncryptString(userProfile.Phone);
            userProfile.Email  = EncryptionEngine.EncryptString(userProfile.Email);
            // userProfile.LoginName = EncryptionEngine.EncryptString(userProfile.LoginName);
            // userProfile.Password = EncryptionEngine.EncryptString(userProfile.Password);
            ObjectMapper.Map(userProfile, userMaster);
            if (userMaster != null && userMaster.UserID > 0)
            {
                isSuccess = UserRepository.UpdateUserProfile(userMaster);
            }
            return(isSuccess);
        }
Ejemplo n.º 24
0
        public QCLoginResponseDTO LoginWebUser(string userName, string password)
        {
            QCLoginResponseDTO result = new QCLoginResponseDTO();
            //generate apikey token
            var APIKey   = AppUtil.GetUniqueKey();
            var APIToken = DateTime.Now.ToString().GetHashCode().ToString("x");

            //authenticate user
            result.loginStatus = UserRepository.LoginWebUser(userName, EncryptionEngine.EncryptString(password));
            result.APIKey      = APIKey;
            result.APIToken    = APIToken;

            //save apikey and token in Database
            if (result.loginStatus > 0)
            {
                RaceRepository.generateAPIKeyToken(APIKey, APIToken, result.loginStatus);
            }

            return(result);
        }
Ejemplo n.º 25
0
        private static void DecryptPasswords(IHostConfig configuration, X509Certificate2 certificate)
        {
            var encryptionMetadata = new Dictionary <string, object> {
                { "privatekey", certificate.PrivateKey }
            };
            var encryptionEngine = EncryptionEngine.Get <RSAEncryptionEngine>();

            if (configuration.Database.Default.IsEncrypted)
            {
                configuration.Database.Default.Password =
                    encryptionEngine.Decrypt(configuration.Database.Default.Password, string.Empty, encryptionMetadata);
                ;
            }

            if (configuration.Runtime.SuperUser.IsEncrypted)
            {
                configuration.Runtime.SuperUser.Password =
                    encryptionEngine.Decrypt(configuration.Runtime.SuperUser.Password, string.Empty, encryptionMetadata);
            }
        }
Ejemplo n.º 26
0
        public CommandOutput OnExecute(CommandInput arguments)
        {
            var      username   = arguments["name"];
            var      password   = arguments["pwd"];
            DateTime nowUtc     = DateTime.UtcNow;
            int      uniqueTime = (nowUtc.Day * 10) + (nowUtc.Month * 100) + ((nowUtc.Year % 100) * 1000);

            string token =
                EncryptionEngine.Get <SHA256Encryption>()
                .Encrypt(String.Format("{0}{1}{2}", uniqueTime, username, password), null, null);

            // Authenticate in DB
            AuthenticationModel authInfo =
                CurrentHostContext.Default.Provider.ConfigurationStore.GetAuthenticatedInfo(username, password, token);

            if (!CurrentHostContext.Default.UserTokens.Contains(token))
            {
                CurrentHostContext.Default.UserTokens.Add(token);
            }

            var authenticationOutput = CurrentContext.Default.Cache.Get(token,
                                                                        () => new AuthenticationOutput
            {
                Token           = token,
                Username        = username,
                IsAuthenticated = authInfo.IsAuthenticated,
                UserId          = authInfo.UserId,
                ExpireUtc       = DateTime.MaxValue
            }, CachePolicy.AlwaysLive);

            var output = new CommandOutput
            {
                PostAction     = CommandOutput.PostCommandAction.None,
                Data           = authenticationOutput,
                DisplayMessage = "Success"
            };

            return(output);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Change password of User
        /// </summary>
        /// <param name="GUID"> uniqe string </param>
        /// <param name="Password">password entered by user</param>
        /// <returns></returns>
        public bool ChangePassword(string GUID, string Password)
        {
            int       OTPExirationHrs = Convert.ToInt32(AppUtil.GetAppSettings(AspectEnums.ConfigKeys.OTPExirationHrs));
            DateTime  StartTime       = DateTime.Now.Subtract(new TimeSpan(OTPExirationHrs, 0, 0));
            DateTime  EndTime         = DateTime.Now;
            OTPMaster objOTP          = HIQAdminContext.OTPMasters.FirstOrDefault(k => k.CreatedDate >= StartTime && k.CreatedDate <= EndTime && k.GUID == GUID);

            if (objOTP != null)
            {
                UserMaster user = HIQAdminContext.UserMasters.FirstOrDefault(k => k.UserID == objOTP.UserID && !k.IsDeleted);
                user.Password = EncryptionEngine.EncryptString(Password);
                HIQAdminContext.Entry(user).State = EntityState.Modified;
                //Delete all previous OTPs
                foreach (var o in HIQAdminContext.OTPMasters.Where(k => k.UserID == user.UserID))
                {
                    HIQAdminContext.OTPMasters.Remove(o);
                }

                return(HIQAdminContext.SaveChanges() > 0);
            }

            return(false);
        }
Ejemplo n.º 28
0
 public UserMaster UserLogin(string email, string password)
 {
     email    = EncryptionEngine.EncryptString(email);
     password = EncryptionEngine.EncryptString(password);
     return(HIQAdminContext.UserMasters.Include("UserRoles").FirstOrDefault(x => x.Email == email && x.Password == password));
 }
Ejemplo n.º 29
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <LoginRequest, LoginRequest>()
     .ForMember(d => d.Username, opt => opt.MapFrom(s => EncryptionEngine.EncryptString(s.Username)))
     .ForMember(d => d.Password, opt => opt.MapFrom(s => EncryptionEngine.EncryptString(s.Password)));
 }
 public async Task <bool> ChangePasswordAsync(string guid, string password)
 {
     password = EncryptionEngine.EncryptString(password);
     return(await _userRepository.ChangePasswordAsync(guid, password));
 }