Esempio n. 1
0
 public BaseApiController(IWebApiContentService mainService)
     : base()
 {
     this.mainService      = mainService;
     this.htmlToViewHelper = mainService.HtmlToViewHelper;
     this.utilService      = mainService.UtilService;
     this.logService       = mainService.LogService;
     this.accountService   = mainService.AccountService;
 }
Esempio n. 2
0
 public ExcelController(IWebApiContentService mainService,
                        IMiscService miscService,
                        IProjectService projectService)
     : base(mainService)
 {
     //this.LogType = "Test";
     //this.LogTypeResponse = "TestResponse";
     this.miscService    = miscService;
     this.projectService = projectService;
 }
Esempio n. 3
0
 public ProjectController(IWebApiContentService mainService,
                          IProjectService projectService,
                          ICustomerService customerService,
                          IMiscService miscService)
     : base(mainService)
 {
     this.projectService          = projectService;
     this.customerService         = customerService;
     this.RaiseErrorMessageEvent += this.GetErrorMessageEvent;
     this.miscService             = miscService;
 }
Esempio n. 4
0
 public FileController(IWebApiContentService mainService,
                       ICustomerFileService customerFileService)
     : base(mainService)
 {
     this.customerFileService = customerFileService;
 }
Esempio n. 5
0
        //private string LogType;
        //private string LogTypeResponse;

        public AlfredController(IWebApiContentService mainService)
            : base(mainService)
        {
        }
Esempio n. 6
0
 public AccountController(IWebApiContentService webApiContentService)
     : base(webApiContentService)
 {
 }
Esempio n. 7
0
        //private string LogType;
        //private string LogTypeResponse;

        public TestController(IWebApiContentService mainService)
            : base(mainService)
        {
            //this.LogType = "Test";
            //this.LogTypeResponse = "TestResponse";
        }
Esempio n. 8
0
 public PanelsController(IWebApiContentService mainService,
                         IPanelService panelService)
     : base(mainService)
 {
     this.panelService = panelService;
 }
Esempio n. 9
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            //context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

            var unityContainer = UnityConfig.GetConfiguredContainer();

            IAccountService accountService = unityContainer.Resolve <IAccountService>();


            UserLoginResultServiceModel loginResult = await accountService.Login(context.UserName, context.Password, false);

            if (loginResult == null)
            {
                context.SetError("invalid_grant", ErrorResources.UserOrEmailNorValid);
                return;
            }
            else
            {
                if (loginResult.Succeeded)
                {
                    string rolesFlag = accountService.GetRolesKeyFlagsForUser(loginResult.LoggedUser.Id);


                    ClaimsIdentity identity = new ClaimsIdentity(context.Options.AuthenticationType);
                    identity.AddClaim(new Claim("sub", context.UserName));
                    identity.AddClaim(new Claim("role", rolesFlag));

                    AuthenticationProperties props;
                    AuthenticationTicket     authTicket;
                    long recentProjectId = 0;

                    if (rolesFlag.ToUpper() != "C")
                    {
                        IWebApiContentService mainService = unityContainer.Resolve <IWebApiContentService>();
                        var rmRecentProject = mainService.GetMostRecentProjectId();

                        if (rmRecentProject.Success)
                        {
                            recentProjectId = rmRecentProject.Value;
                        }
                    }

                    var name = string.Format("{0} {1}", loginResult.LoggedUser.Name, loginResult.LoggedUser.Surname);
                    if (string.IsNullOrWhiteSpace(name))
                    {
                        name = loginResult.LoggedUser.UserName;
                    }

                    props = new AuthenticationProperties(
                        new Dictionary <string, string>
                    {
                        { "roleFlag", rolesFlag },
                        { "name", name },
                        { "rpId", recentProjectId.ToString() }
                    }
                        );

                    authTicket = new AuthenticationTicket(identity, props);
                    context.Validated(authTicket);
                }
                else
                {
                    context.SetError("invalid_grant", loginResult.FailMessage);
                    return;
                }
            }
        }
Esempio n. 10
0
 public UploadController(IWebApiContentService mainService,
                         IFileService fileService)
     : base(mainService)
 {
     this.fileService = fileService;
 }