Ejemplo n.º 1
0
        /// <summary>
        /// Add user tokens
        /// </summary>
        /// <param name="tokens">List of already added tokens</param>
        /// <param name="user">User</param>
        public virtual void AddUserTokens(IList <Token> tokens, User user)
        {
            tokens.Add(new Token("User.Email", user.Email));
            tokens.Add(new Token("User.Username", user.Username));
            tokens.Add(new Token("User.FullName", user.GetFullName()));
            tokens.Add(new Token("User.FirstName", user.GetAttribute <string>(SystemUserAttributeNames.FirstName)));
            tokens.Add(new Token("User.LastName", user.GetAttribute <string>(SystemUserAttributeNames.LastName)));
            tokens.Add(new Token("User.VatNumber", user.GetAttribute <string>(SystemUserAttributeNames.VatNumber)));

            var customAttributesXml = user.GetAttribute <string>(SystemUserAttributeNames.CustomUserAttributes);

            tokens.Add(new Token("User.CustomAttributes", _userAttributeFormatter.FormatAttributes(customAttributesXml), true));


            //note: we do not use SEO friendly URLS because we can get errors caused by having .(dot) in the URL (from the email address)
            //TODO add a method for getting URL (use routing because it handles all SEO friendly URLs)
            var passwordRecoveryUrl  = string.Format("{0}passwordrecovery/confirm?token={1}&email={2}", GetApplicationUrl(), user.GetAttribute <string>(SystemUserAttributeNames.PasswordRecoveryToken), HttpUtility.UrlEncode(user.Email));
            var accountActivationUrl = string.Format("{0}user/activation?token={1}&email={2}", GetApplicationUrl(), user.GetAttribute <string>(SystemUserAttributeNames.AccountActivationToken), HttpUtility.UrlEncode(user.Email));
            var emailRevalidationUrl = string.Format("{0}user/revalidateemail?token={1}&email={2}", GetApplicationUrl(), user.GetAttribute <string>(SystemUserAttributeNames.EmailRevalidationToken), HttpUtility.UrlEncode(user.Email));
            var wishlistUrl          = string.Format("{0}wishlist/{1}", GetApplicationUrl(), user.UserGuid);

            tokens.Add(new Token("User.PasswordRecoveryURL", passwordRecoveryUrl, true));
            tokens.Add(new Token("User.AccountActivationURL", accountActivationUrl, true));
            tokens.Add(new Token("User.EmailRevalidationURL", emailRevalidationUrl, true));
            tokens.Add(new Token("Wishlist.URLForUser", wishlistUrl, true));

            //event notification
            _eventPublisher.EntityTokensAdded(user, tokens);
        }
        /// <summary>
        /// Add user tokens
        /// </summary>
        /// <param name="tokens">List of already added tokens</param>
        /// <param name="user">User</param>
        public virtual void AddUserTokens(IList <Token> tokens, User user)
        {
            tokens.Add(new Token("User.Email", user.Email));
            tokens.Add(new Token("User.Username", user.Username));
            tokens.Add(new Token("User.FullName", _userService.GetUserFullName(user)));
            tokens.Add(new Token("User.FirstName", _genericAttributeService.GetAttribute <string>(user, NopUserDefaults.FirstNameAttribute)));
            tokens.Add(new Token("User.LastName", _genericAttributeService.GetAttribute <string>(user, NopUserDefaults.LastNameAttribute)));
            tokens.Add(new Token("User.VatNumber", _genericAttributeService.GetAttribute <string>(user, NopUserDefaults.VatNumberAttribute)));

            var customAttributesXml = _genericAttributeService.GetAttribute <string>(user, NopUserDefaults.CustomUserAttributes);

            tokens.Add(new Token("User.CustomAttributes", _userAttributeFormatter.FormatAttributes(customAttributesXml), true));

            //note: we do not use SEO friendly URLS for these links because we can get errors caused by having .(dot) in the URL (from the email address)
            var passwordRecoveryUrl  = RouteUrl(routeName: "PasswordRecoveryConfirm", routeValues: new { token = _genericAttributeService.GetAttribute <string>(user, NopUserDefaults.PasswordRecoveryTokenAttribute), email = user.Email });
            var accountActivationUrl = RouteUrl(routeName: "AccountActivation", routeValues: new { token = _genericAttributeService.GetAttribute <string>(user, NopUserDefaults.AccountActivationTokenAttribute), email = user.Email });
            var emailRevalidationUrl = RouteUrl(routeName: "EmailRevalidation", routeValues: new { token = _genericAttributeService.GetAttribute <string>(user, NopUserDefaults.EmailRevalidationTokenAttribute), email = user.Email });
            var wishlistUrl          = RouteUrl(routeName: "Wishlist", routeValues: new { userGuid = user.UserGuid });

            tokens.Add(new Token("User.PasswordRecoveryURL", passwordRecoveryUrl, true));
            tokens.Add(new Token("User.AccountActivationURL", accountActivationUrl, true));
            tokens.Add(new Token("User.EmailRevalidationURL", emailRevalidationUrl, true));
            tokens.Add(new Token("Wishlist.URLForUser", wishlistUrl, true));

            //event notification
            _eventPublisher.EntityTokensAdded(user, tokens);
        }
Ejemplo n.º 3
0
        private string GetCustomUserAttributes(User user)
        {
            var selectedUserAttributes = _genericAttributeService.GetAttribute <string>(user, NopUserDefaults.CustomUserAttributes);

            return(_userAttributeFormatter.FormatAttributes(selectedUserAttributes, ";"));
        }