public CPApiController(ILogs logs
                               , IConfiguration configuration
                               , SysTemplateDetailService templateDetailService
                               , SysTemplateService templateService
                               , SysTemplatePropertyService templatePropertyService
                               , CPMenuService menuService
                               , CPUserService userService
                               , CPRoleService roleService
                               , CPLangService langService
                               , Security security)
        {
            _configuration          = configuration;
            _logs                   = logs;
            _menu                   = new WebMenu();
            _security               = security;
            _templateDetailsService = templateDetailService;
            _templateService        = templateService;
            _menuService            = menuService;
            _propertyService        = templatePropertyService;
            _userService            = userService;
            _roleService            = roleService;
            _langService            = langService;

            _currentLang = StartUp.CurrentLang;
        }
 public ModChaptersController(ModChapterService service, CPUserService userService, ModCourseService courseService, ModLessonService lessonService)
 {
     _service       = service;
     _userService   = userService;
     _courseService = courseService;
     _lessonService = lessonService;
 }
 public CPApiController(ILogs logs
                        , IConfiguration configuration
                        , CPMenuService menuService
                        , CPUserService userService
                        , CPRoleService roleService
                        , CPLangService langService
                        , Security security
                        , ModLessonService lessonService
                        , ModLessonPartService lessonPartService
                        , ModLessonExtendService lessonExtendService
                        , ModLessonPartAnswerService answerService
                        , CPLoginLogService loginLogService
                        , FileProcess fileProcess)
 {
     _configuration        = configuration;
     _logs                 = logs;
     _menu                 = new WebMenu();
     _security             = security;
     _menuService          = menuService;
     _userService          = userService;
     _roleService          = roleService;
     _langService          = langService;
     _lessionService       = lessonService;
     _lessionPartService   = lessonPartService;
     _lessionExtendService = lessonExtendService;
     _loginLogService      = loginLogService;
     _answerService        = answerService;
     _fileProcess          = fileProcess;
     _currentLang          = StartUp.CurrentLang;
     _currentUser          = StartUp.CurrentUser;
 }
Example #4
0
        public CPUserController(CPUserService userService, CPRoleService roleService)
        {
            _service     = userService;
            _roleService = roleService;
            var data = _roleService.GetAll();

            _listRoles = data?.ToList();
        }
Example #5
0
 public CPAccountsController(IHostingEnvironment environment)
 {
     _hostingEnvironment = environment;
     _userService        = new CPUserService();
     _loginLogService    = new CPLoginLogService();
     _roleService        = new CPRoleService();
     _ilogs = new Logs(_hostingEnvironment.WebRootPath);
 }
Example #6
0
 public CPAccountsController(IHostingEnvironment environment,
                             CPUserService userService,
                             CPLoginLogService loginLogService,
                             CPRoleService roleService)
 {
     _hostingEnvironment = environment;
     _userService        = userService;
     _loginLogService    = loginLogService;
     _roleService        = roleService;
     _ilogs = new Logs(_hostingEnvironment.WebRootPath);
 }
 public ModGradesController(ModGradeService service, CPUserService userService, ModProgramService programService)
 {
     _service        = service;
     _userService    = userService;
     _programService = programService;
 }
Example #8
0
        private static ClaimsPrincipal GetCurrentUser(this HttpContext context)
        {
            string token = context.GetValue(Cookies.DefaultLogin, false);

            if (string.IsNullOrEmpty(token))
            {
                return(null);
            }
            else
            {
                // neeus co cache
                var cache = CacheExtends.GetDataFromCache <ClaimsPrincipal>(token);
                if (cache != null)
                {
                    return(cache);
                }
                // ko co cache
                var    logs  = new CPLoginLogService();
                string email = logs.GetEmailFromDb(token);
                if (string.IsNullOrEmpty(email))
                {
                    return(null);
                }
                else
                {
                    var account = new CPUserService();
                    var user    = account.GetItemByEmail(email);
                    if (user == null)
                    {
                        return(null);
                    }
                    else
                    {
                        var role  = new CPRoleService();
                        var irole = role.GetItemByID(user.RoleID);
                        if (role == null)
                        {
                            return(null);
                        }
                        var claims = new List <Claim>
                        {
                            new Claim(ClaimTypes.Email, user.Email),
                            new Claim(ClaimTypes.Name, user.Name),
                            new Claim(ClaimTypes.Role, irole.Code),
                            new Claim("RoleID", irole.ID.ToString())
                        };
                        var claimsIdentity = new ClaimsIdentity(claims, Cookies.DefaultLogin);

                        var authenProperties = new AuthenticationProperties
                        {
                            IsPersistent = true,
                            ExpiresUtc   = DateTime.UtcNow.AddMinutes(Cookies.ExpiresLogin)
                        };
                        ClaimsPrincipal claim = new ClaimsPrincipal();
                        claim.AddIdentity(claimsIdentity);

                        CacheExtends.SetObjectFromCache(token, Cookies.ExpiresLogin, claim);

                        return(claim);
                    }
                }
            }
        }
 public CPUserController()
 {
     _service     = new CPUserService();
     _roleService = new CPRoleService();
     _listRoles   = _roleService.GetAllItem();
 }