Example #1
0
        public IAuthenticationType GetAuthentcationType(HttpMethod httpMethod)
        {
            var res = new AnonymousAuthentication();

            try
            {
                var method = Controller.GetMethods().SingleOrDefault(m => m.Name.Equals(MethodName, StringComparison.OrdinalIgnoreCase) && m.CheckMethod(httpMethod));
                if (method.GetCustomAttribute <AuthenticationTypeAttribute>() == null)
                {
                    var classAttr = Controller.GetCustomAttribute <AuthenticationTypeAttribute>();
                    if (classAttr == null)
                    {
                        return(res);
                    }
                    else
                    {
                        return(classAttr.AuthentcationType);
                    }
                }
                else
                {
                    return(method.GetCustomAttribute <AuthenticationTypeAttribute>().AuthentcationType);
                }
            }
            catch {
                throw new Exception($"Action method is not single in controller!{GetControllerName()} - {GetActionName()}");
            }
        }
Example #2
0
 public Authentication(
     string site,
     AppCmd appCmd)
 {
     Anonymous = new AnonymousAuthentication(site, appCmd);
 }