Esempio n. 1
0
        public static GrantResourceOwnerCredentialsContext Create(HttpContext context)
        {
            var result      = default(GrantResourceOwnerCredentialsContext);
            var requestForm = context.Request.Form;

            if (requestForm.ContainsKey(Parameters.GrandType))
            {
                var grandTypeValue = requestForm[Parameters.GrandType].FirstOrDefault();
                if (grandTypeValue == Parameters.Password)
                {
                    var userName = requestForm[Parameters.Username].FirstOrDefault();
                    var password = requestForm[Parameters.Password].FirstOrDefault();

                    result = new GrantResourceOwnerCredentialsContext(context, userName, password);
                }
            }
            return(result);
        }
Esempio n. 2
0
        public static GrantResourceOwnerCredentialsContext Create(HttpContext context)
        {
            const string grandTypeParam = "grant_type";
            const string userNameParam  = "username";
            const string passwordParam  = "password";

            var result      = default(GrantResourceOwnerCredentialsContext);
            var requestForm = context.Request.Form;

            if (requestForm.ContainsKey(grandTypeParam))
            {
                var grandTypeValue = requestForm[grandTypeParam].FirstOrDefault();
                if (grandTypeValue == passwordParam)
                {
                    var userName = requestForm[userNameParam].FirstOrDefault();
                    var password = requestForm[passwordParam].FirstOrDefault();

                    result = new GrantResourceOwnerCredentialsContext(context, userName, password);
                }
            }
            return(result);
        }