#pragma warning disable 1998
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
#pragma warning restore 1998
        {
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
            var user = UserFunctions.GetUser(context.Password, context.UserName);

            if (user == null)
            {
                context.SetError("invalid_grant", "The user name or password is incorrect.");
                return;
            }

            var identity = new ClaimsIdentity(context.Options.AuthenticationType);

            if (identity.IsAuthenticated)//&& (user.IsAdmin() || user.IsActive()))
            {
                //TODO : user claims
                //identity.AddClaim(new Claim("sub", context.UserName));

                //string role;
                //role = user.IsAdmin() ? "admin" : "user";
                //identity.AddClaim(new Claim(ClaimTypes.Role, role));
                identity.AddClaim(new Claim(ClaimTypes.Name, user.Name));
                identity.AddClaim(new Claim(ClaimTypes.Surname, user.Surname));
                identity.AddClaim(new Claim(ClaimTypes.Email, user.Email));
                identity.AddClaim(new Claim(ClaimTypes.Dns, context.Request.RemoteIpAddress));
                context.Validated(identity);
            }
            else
            {
                context.SetError("invalid_grant", "This user cannot be authenticated.");
            }
        }
Beispiel #2
0
        public async void GetUser()
        {
            UserFunctions uf = new UserFunctions();
            User          u  = new User();

            pictureBox1.Image = Properties.Resources.fingerdumb;

            try
            {
                u = await uf.GetUser(usersearchbox.Text);

                firstnamelabel.Text = u.NationalRegInfo.FirstName;
                lastnamelabel.Text  = u.NationalRegInfo.LastName;
                ninlabel.Text       = u.NationalRegInfo.NIN;
                phonelabel.Text     = u.PhoneNumber;
                emaillabel.Text     = u.Email;
                UserId          = u.ID;
                savebtn.Enabled = true;

                if (u.FingerPrint != "")
                {
                    button2.Enabled   = false;
                    savebtn.Enabled   = false;
                    pictureBox1.Image = new Imc().ToBitmap(new Imc().ToByteArr(u.FingerPrint));
                }
                else
                {
                    button2.Enabled = true;
                    savebtn.Enabled = true;
                }
            }
            catch
            {
                firstnamelabel.Text = "null";
                lastnamelabel.Text  = "null";
                ninlabel.Text       = "null";
                phonelabel.Text     = "null";
                emaillabel.Text     = "null";
                savebtn.Enabled     = false;
                button2.Enabled     = false;
            }
        }
Beispiel #3
0
        public async void GetPrintUser()
        {
            UserFunctions uf = new UserFunctions();
            User          u  = new User();

            try
            {
                int UserID = await uf.GetDriver(new Imc().ToBase64String(new Imc().ToByteArr(ScannedFingerPrint)));

                u = await uf.GetUser(UserID);


                firstnamelabel.Text = u.NationalRegInfo.FirstName;
                lastnamelabel.Text  = u.NationalRegInfo.LastName;
                ninlabel.Text       = u.NationalRegInfo.NIN;
                phonelabel.Text     = u.PhoneNumber;
                emaillabel.Text     = u.Email;
                UserId = u.ID;
            }
            catch
            {
            }
        }