Example #1
0
        public UserCredentials Post([FromBody] LoginAction loginAction)
        {
            IStoreUserService storeUserService = AutofacBootstapper.CurrentContainer.ResolveOptional <IStoreUserService>(
                new NamedParameter("companyId", loginAction.CompanyId),
                new NamedParameter("storeId", loginAction.StoreId),
                new NamedParameter("machineSn", loginAction.MachineSn),
                new NamedParameter("deviceSn", loginAction.DeviceSn)
                );
            var result    = storeUserService.Login(loginAction.Account, loginAction.Password, loginAction.Practice);
            var principal = new StoreUserPrincipal(result);

            Thread.CurrentPrincipal = principal;
            if (HttpContext.Current != null)
            {
                HttpContext.Current.User = principal;
            }
            return(result);
        }
        private bool ValidateTicket(string strTicket)
        {
            IStoreUserService storeUserService = AutofacBootstapper.CurrentContainer.ResolveOptional <IStoreUserService>(
                new NamedParameter("token", strTicket)
                );
            var user = storeUserService.GetLoginCredentials();

            if (user == null)
            {
                return(false);
            }
            var principal = new StoreUserPrincipal(user);

            Thread.CurrentPrincipal = principal;
            if (HttpContext.Current != null)
            {
                HttpContext.Current.User = principal;
            }
            return(true);
        }