/// <summary>
        /// Sets the cookies.
        /// </summary>
        /// <param name="umbracoContext">The umbraco context.</param>
        /// <param name="isLocalHost">if set to <c>true</c> [is local host].</param>
        /// <param name="emailAddress">The email address.</param>
        /// <param name="rememberMe">if set to <c>true</c> [remember me].</param>
        /// <param name="password">The password.</param>
        /// <inheritdoc />
        public void SetCookies(
            UmbracoContext umbracoContext,
            bool isLocalHost,
            string emailAddress,
            bool rememberMe,
            string password)
        {
            string emailKey      = AuthenticationConstants.EmailAddress;
            string rememberMeKey = AuthenticationConstants.RememberMe;
            string passwordKey   = AuthenticationConstants.Password;

            if (rememberMe)
            {
                string encryptedEmailAddress = encryptionService.EncryptString(emailAddress);
                cookieService.SetValue(emailKey, encryptedEmailAddress);

                string encryptedRememberMe = encryptionService.EncryptString(true.ToString());
                cookieService.SetValue(rememberMeKey, encryptedRememberMe);

                IPublishedContent customerNode = settingsService.GetCustomerNode();

                CustomerModel model = new CustomerModel(customerNode);

                if (isLocalHost || model.SavePassword)
                {
                    string encryptedPassword = encryptionService.EncryptString(password);
                    cookieService.SetValue(passwordKey, encryptedPassword);
                }

                else
                {
                    cookieService.Expire(passwordKey);
                }
            }

            else
            {
                cookieService.Expire(emailKey);
                cookieService.Expire(passwordKey);
                cookieService.Expire(rememberMeKey);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the appointment identifier.
        /// </summary>
        /// <param name="autoAllocate">The automatic allocate.</param>
        /// <param name="appointmentId">The appointment identifier.</param>
        /// <returns></returns>
        internal int?GetAppointmentId(
            string autoAllocate,
            string appointmentId)
        {
            int?id = null;

            if (string.IsNullOrEmpty(appointmentId) == false)
            {
                string appId = encryptionService.DecryptString(appointmentId);

                id = Convert.ToInt32(appId);
            }

            else if (string.IsNullOrEmpty(autoAllocate) == false &&
                     autoAllocate.ToLower() == "y")
            {
                id = cookieService.GetValue <int>(AppointmentConstants.LastAppointmentIdCookie);
            }

            //// remove the cookie so it doesnt get allocated to the next payment.
            cookieService.Expire(AppointmentConstants.LastAppointmentIdCookie);

            return(id);
        }