using PageAdmin.Utils;
using System;
using System.Web.Mvc;

namespace PageAdmin.Web.Areas.Member.Controllers.FindPassword
{

    /// <summary>
    /// 找回密码
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
    public class ConfigAttribute : ActionFilterAttribute
    {
        //检测验证码，判断登录等等
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (CookieHelper.Get("UserToken") != null)
            {
                filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary()
                {
                   { "controller", "Default" },
                   { "action", "Index" }
                });
                return;
            }

            dynamic configData = XmlHelper.AllNodeValue("configuration", "/Config/MemberFindPassword.config", true);
            filterContext.Controller.ViewBag.Open = configData.Open;
            filterContext.Controller.ViewBag.FindByEmail = configData.FindByEmail;
            filterContext.Controller.ViewBag.FindByMobile = configData.FindByMobile;
            filterContext.Controller.ViewBag.VerificationCode = configData.VerificationCode;
        }

    }
}
