Example #1
0
        public async Task <ActionResult> POApprover()
        {
            var nh       = new NHibernateUserStore();
            var response = new HttpResponseMessage(HttpStatusCode.OK);

            var user = (UserModel)HttpContext.Session[Config.GetAppSetting("SessionKey")];

            //UserModel user = null;
            if (user != null)
            {
                //user = (UserModel)task.GetType().GetProperty("Result").GetValue(task);
            }
            else if (CurrentUserSession.userSecurityStampCookie != null)
            {
                user = await nh.FindByStampAsync(CurrentUserSession.userSecurityStampCookie);

                HttpContext.Session[Config.GetAppSetting("SessionKey")] = user;
                var owinAuthentication = new OwinAuthenticationService(HttpContext);
                owinAuthentication.SignIn(user);
            }
            else
            {
                return(RedirectToAction("Login", "User"));
            }
            var nhps = new NHibernatePOStore();
            var pr   = await nhps.FindPOApprovalAsync(user.employee.position);

            return(View(pr));
        }
Example #2
0
        public string Post(LoginViewModel value)
        {
            string        Url  = "";
            LoginAccessor la   = new LoginAccessor();
            var           user = la.LogIn(value);

            if (user.Result != null)
            {
                var session            = HttpContext.Current.Session;
                var owinAuthentication = new OwinAuthenticationService(new HttpContextWrapper(HttpContext.Current));

                owinAuthentication.SignIn((UserModel)user.GetType().GetProperty("Result").GetValue(user));
                session[Config.GetAppSetting("SessionKey")] = (UserModel)user.GetType().GetProperty("Result").GetValue(user);

                Url = "../PR/PRShop";
            }
            return(Url);
        }
Example #3
0
        public async Task Invoke(IDictionary <string, object> env)
        {
            var ctx = new OwinContext(env);

            using (var db = new BrockAllen.MembershipReboot.Ef.DefaultUserAccountRepository())
            {
                var settings = SecuritySettings.FromConfiguration();
                var mrConfig = new MembershipRebootConfiguration(settings);
                mrConfig.ConfigureCookieBasedTwoFactorAuthPolicy(new OwinCookieBasedTwoFactorAuthPolicy(env));

                var appInfo = new OwinApplicationInformation(env,
                                                             "Test", "Test Email Signature",
                                                             "UserAccount/Login",
                                                             "UserAccount/Register/Confirm/",
                                                             "UserAccount/Register/Cancel/",
                                                             "UserAccount/PasswordReset/Confirm/",
                                                             "UserAccount/ChangeEmail/Confirm/");

                var emailFormatter = new EmailMessageFormatter(appInfo);
                if (settings.RequireAccountVerification)
                {
                    // uncomment if you want email notifications -- also update smtp settings in web.config
                    //config.AddEventHandler(new EmailAccountCreatedEventHandler(emailFormatter));
                }
                // uncomment if you want email notifications -- also update smtp settings in web.config
                //config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));

                var uaSvc = new UserAccountService(mrConfig, db);
                var anSvc = new OwinAuthenticationService(uaSvc, env);
                try
                {
                    ctx.SetUserAccountService(uaSvc);
                    ctx.SetAuthenticationService(anSvc);

                    await next(env);
                }
                finally
                {
                    ctx.SetUserAccountService(null);
                    ctx.SetAuthenticationService(null);
                }
            }
        }
Example #4
0
        // GET: PR
        public async Task <ActionResult> PRShop(string itemType = "Catalog")
        {
            NHibernateUserStore nh = new NHibernateUserStore();

            ViewData["ApiServer"] = Config.GetApiServerURL();

            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);

            //var task =  (Task)HttpContext.Session[Config.GetAppSetting("SessionKey")];
            var user = (UserModel)HttpContext.Session[Config.GetAppSetting("SessionKey")];

            //UserModel user=null;
            if (user != null)
            {
                //user =(UserModel) task.GetType().GetProperty("Result").GetValue(task);
            }
            else if (CurrentUserSession.userSecurityStampCookie != null)
            {
                user = await nh.FindByStampAsync(CurrentUserSession.userSecurityStampCookie);

                HttpContext.Session[Config.GetAppSetting("SessionKey")] = user;

                var owinAuthentication = new OwinAuthenticationService(HttpContext);
                owinAuthentication.SignIn(user);
            }
            else
            {
                return(RedirectToAction("Login", "User"));
            }
            var nhps  = new NHibernatePRStore();
            var lines = await nhps.PRLinesCreatedAsync(user);

            ViewData["cartCount"] = lines.Count;

            ViewData["itemType"]      = itemType;
            ViewData["ItemImagePath"] = Config.GetAppSetting("ItemImagePath");

            return(View(user));
        }
Example #5
0
        public async Task <ActionResult> CreatePR(IList <PrLinesViewModel> value)
        {
            List <PRLinesModel> lines = new List <PRLinesModel>();
            var nhps = new NHibernatePRStore();
            var nh   = new NHibernateUserStore();
            var nhcs = new NHibernateCompanyStore();
            var user = (UserModel)HttpContext.Session[Config.GetAppSetting("SessionKey")];

            //UserModel user = null;
            if (user != null)
            {
                //user = (UserModel)task.GetType().GetProperty("Result").GetValue(task);
            }
            else if (CurrentUserSession.userSecurityStampCookie != null)
            {
                user = await nh.FindByStampAsync(CurrentUserSession.userSecurityStampCookie);

                HttpContext.Session[Config.GetAppSetting("SessionKey")] = user;
                var owinAuthentication = new OwinAuthenticationService(HttpContext);
                owinAuthentication.SignIn(user);
            }
            else
            {
                return(RedirectToAction("Login", "User"));
            }
            ViewData["SmallLogo"] = Config.GetCompanyLogo(user.employee.Company.SmallLogo);
            ViewData["Employee"]  = user.employee;
            ViewData["Section"]   = await nhcs.TeamEmployeeAsync(user.employee.Team);

            foreach (var item in value)
            {
                var line = await nhps.GetPRLineAsync(item.Id);

                lines.Add(line);
            }
            return(PartialView(lines));
        }
Example #6
0
 public AccountsApiController(UserService svc, OwinAuthenticationService oas)
 {
     _svc = svc;
     _oas = oas;
 }