示例#1
0
        public static bool UserNameandPassword(string name, string pass)
        {
            using (serkanISGEntities1 db = new serkanISGEntities1())
            {
                return(db.PERSONEL.Any(x => x.KULLANICI_ADI.Equals(name, StringComparison.OrdinalIgnoreCase) && x.SIFRE == pass));
            }

            //if(name=="sekoccan" && pass == "x1")
            //{
            //    return true;
            //}
            //else
            //{
            //    return false;
            //}
        }
示例#2
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            serkanISGEntities1 db  = new serkanISGEntities1();
            PERSONEL           per = new PERSONEL();

            per = db.PERSONEL.FirstOrDefault(i => i.KULLANICI_ADI == context.UserName);



            if (per != null && per.KULLANICI_ADI.ToLower() == context.UserName.ToLower() && context.Password == per.SIFRE)
            {
                var identity = new ClaimsIdentity(context.Options.AuthenticationType);
                identity.AddClaim(new Claim("sub", context.UserName));
                identity.AddClaim(new Claim("role", "user"));
                context.Validated(identity);
            }
            else
            {
                context.SetError("Oturum Hatası", "Kullanıcı adı veya Şifre Hatalı");
            }
        }