예제 #1
0
        protected void Application_PostAuthenticateRequest(object sender, EventArgs e)
        {
            var ctx = HttpContext.Current;

            if (ctx.Request.IsAuthenticated)
            {
                TrebovanjeNabavkeContext trebovanjeNabavkeContext = new TrebovanjeNabavkeContext();
                var authCookie = ctx.Request.Cookies[FormsAuthentication.FormsCookieName];
                if (authCookie == null)
                {
                    var authTicket = new FormsAuthenticationTicket(
                        1,
                        User.Identity.Name,
                        DateTime.Now,
                        DateTime.Now.AddMinutes(30),
                        false,
                        trebovanjeNabavkeContext.vRadniks.FirstOrDefault(t => t.KorisnickoIme == User.Identity.Name).NazivUloge

                        //string.Join(",", korisnik.KorisnikUlogas.Select(o => o.Uloga.Naziv).Distinct())// ukoliko jedan radnik moze imati vise uloga
                        );

                    var encTicket = FormsAuthentication.Encrypt(authTicket);
                    var cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
                    Response.Cookies.Add(cookie);
                    authCookie = ctx.Request.Cookies[FormsAuthentication.FormsCookieName];
                }
                if (authCookie != null)
                {
                    var authTicket = FormsAuthentication.Decrypt(authCookie.Value);

                    ctx.User = new System.Security.Principal.GenericPrincipal(
                        new System.Security.Principal.GenericIdentity(authTicket.Name, "Windows"), authTicket.UserData.Split(','));
                }
            }
        }
예제 #2
0
 public OdobravanjeNabavkeController()
 {
     trebovanjeNabavkeContext = new TrebovanjeNabavkeContext();
 }
 //Konstruktor za bazu
 public MarketingController()
 {
     trebovanjeNabavkeContext = new TrebovanjeNabavkeContext();
 }
예제 #4
0
 public EmailController()
 {
     trebovanjeNabavkeContext = new TrebovanjeNabavkeContext();
 }
 public DataTableServerSideUcitavanjeController()
 {
     trebovanjeNabavkeContext = new TrebovanjeNabavkeContext();
 }
 public SkladisteController()
 {
     trebovanjeNabavkeContext = new TrebovanjeNabavkeContext();
 }