Exemple #1
0
        private void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var p = NinjectWebCommon.GetInstance <IGetFilmsFromWebService>();

            var s = p.Get();

            var t = NinjectWebCommon.GetInstance <IFilmService>();

            t.SaveFilmsFromWeb(s);
        }
Exemple #2
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            var authRepository = NinjectWebCommon.GetInstance <IUserRepository>();
            var user           = await authRepository.ValidateUser(context.UserName,
                                                                   context.Password);

            if (user != null)
            {
                var identity = new ClaimsIdentity(context.Options.AuthenticationType);
                identity.AddClaim(new Claim("Username", context.UserName));
                identity.AddClaim(new Claim("Password", context.Password));
                identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()));
                context.Validated(identity);
            }
            else
            {
                context.SetError("invalid_grant", "The user name or password is      incorrect.");
                return;
            }
        }