コード例 #1
0
ファイル: UserService.cs プロジェクト: tadmcclellan/SEAM
        public UserService(IPrincipal identity, CTX ctx)
        {
            _identity = identity;
            _ctx = ctx;

            if (identity != null)
            {
                User = ctx.DBUsers.Where(x => x.username == identity.Identity.Name).FirstOrDefault<DBUser>();
            }
        }
コード例 #2
0
ファイル: UnityConfig.cs プロジェクト: tadmcclellan/SEAM
        public static void RegisterComponents(HttpConfiguration config)
        {
            var container = new UnityContainer();

            // register all your components with the container here
            // it is NOT necessary to register your controllers

            CTX ctx = new CTX();

            container.RegisterType<IUserController, UserController>
                (
                new HierarchicalLifetimeManager(),
                new InjectionConstructor(ctx)
                );

            container.RegisterType<IBaseController<Role>, BaseController<Role>>
            (
                new HierarchicalLifetimeManager(),
                new InjectionConstructor(ctx)
            );
            container.RegisterType<IBaseController<Thing>, BaseController<Thing>>
            (
                new HierarchicalLifetimeManager(),
                new InjectionConstructor(ctx)
            );
            container.RegisterType<IBaseController<Nav>, BaseController<Nav>>
            (
                new HierarchicalLifetimeManager(),
                new InjectionConstructor(ctx)
            );
            container.RegisterType<IBaseController<Mapping>, BaseController<Mapping>>
            (
                new HierarchicalLifetimeManager(),
                new InjectionConstructor(ctx)
            );
            container.RegisterType<IBaseController<ObjectType>, BaseController<ObjectType>>
            (
                new HierarchicalLifetimeManager(),
                new InjectionConstructor(ctx)
            );

            DependencyResolver.SetResolver(new Unity.Mvc5.UnityDependencyResolver(container));

            config.DependencyResolver = new UnityResolver(container);//new Unity.WebApi.UnityDependencyResolver(container);
        }
コード例 #3
0
ファイル: UserController.cs プロジェクト: tadmcclellan/SEAM
 public UserController(CTX _ctx)
 {
     ctx = _ctx;
 }
コード例 #4
0
 public RefreshTokenService()
 {
     _ctx = new CTX();
 }
コード例 #5
0
ファイル: UserService.cs プロジェクト: tadmcclellan/SEAM
        public DBUser IsValidUser(string username, string password)
        {
            CTX ctx = new CTX();
            DBUser user;

            Boolean useForms = true;
            Boolean.TryParse(ConfigurationManager.AppSettings["Forms"], out useForms);

            if (!useForms)
            {
                //if the user name is blank... check for the user from windows auth and pass it.
                var identity = System.Security.Principal.WindowsIdentity.GetCurrent();
                username = identity.Name;
                user = ctx.DBUsers.Where(x => x.username == username).FirstOrDefault<DBUser>();
                if (user == null)
                {
                    //user auth via windows auth but not in database so add him to db and auth

                    var _User = new DBUser();
                    _User.authtype = identity.AuthenticationType;
                    _User.username = username;
                    ctx.DBUsers.Add(_User);
                    ctx.SaveChanges();
                    User = _User;
                    return _User;

                }
                else
                {

                    User = user;
                    return user;

                }

            }
            else
            {

                if (username == string.Empty || username == null)
                {
                    return null;

                }

                user = ctx.DBUsers.Where(x => x.username == username).FirstOrDefault<DBUser>();

                if (user == null)
                {
                    return null;
                }

                if (HashingService.ValidateHash(user.password, password))
                {

                    User = user;
                    return user;
                }
                else
                {
                    return null;
                }

            }
        }