예제 #1
0
        public async Task EditAsync(UserRoleModel model)
        {
            var item = await _repository.GetAsync(model.Id);

            UserRoleFactory.Create(model, item, _userId);
            _repository.Edit(item);
            await _unitOfWork.SaveChangesAsync();
        }
예제 #2
0
 internal Workflow(Assembly botAssembly, IComponentContext context)
 {
     this._controllersService          = new ControllersService(context, botAssembly, context.Resolve <BotCommandsService>(), context.Resolve <CommandsContainer>());
     this._commandParser               = context.Resolve <CommandParser>();
     this._middlewaresService          = context.Resolve <MiddlewaresService>();
     this._discordServerContextFactory = context.Resolve <DiscordServerContextFactory>();
     this._userContextsFactory         = context.Resolve <UserContextsFactory>();
     this._channelContextFactory       = context.Resolve <ChannelContextFactory>();
     this._userRoleFactory             = context.Resolve <UserRoleFactory>();
 }
예제 #3
0
        public LoginController()
        {
            _userFactory     = new UserFactory();
            _UserRoleFactory = new UserRoleFactory();
            _LanguageFactory = new LanguageFactory();
            _baseFactory     = new BaseFactory();

            var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

            ViewBag.Version = string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
        }
        public async Task <UserRole> CreateNewRole(NewUserRole role, DiscordServerContext discordServer)
        {
            var permissionsValue = role.Permissions.GetRawValue();

            var guild = await this._restClient.GetGuildAsync(discordServer.Id);

            var restRole = await guild.CreateRoleAsync(role.Name, new GuildPermissions(permissionsValue), isMentionable : false);

            var userRole = new UserRoleFactory().Create(restRole);

            return(userRole);
        }
 public DiscordClientRolesService(DiscordSocketClient client, UserRoleFactory userRoleFactory)
 {
     this._client              = client;
     this._userRoleFactory     = userRoleFactory;
     this._client.Ready       += () => Task.Run(() => this._roles = this._client.Guilds.SelectMany(x => x.Roles).ToList());
     this._client.RoleCreated += this.AddRole;
     this._client.RoleCreated += x => this.RoleCreated(x);
     this._client.RoleDeleted += this.RemoveRole;
     this._client.RoleDeleted += x => this.RoleRemoved(x);
     this._client.RoleUpdated += this.UpdateRole;
     this._client.RoleUpdated += (from, to) => this.RoleUpdated(from, to);
 }
 /// <summary>
 /// 转换为用户角色实体
 /// </summary>
 /// <param name="dto">用户角色数据传输对象</param>
 public static UserRole ToEntity3(this UserRoleDto dto)
 {
     if (dto == null)
     {
         return(new UserRole());
     }
     return(UserRoleFactory.Create(
                userRoleId: dto.Id.ToGuid(),
                roleId: dto.RoleId,
                userId: dto.UserId,
                version: dto.Version
                ));
 }
예제 #7
0
파일: Server.cs 프로젝트: Zilib/Watchman
        public static async Task <UserRole> CreateNewRole(NewUserRole role, DiscordServerContext discordServer)
        {
            var permissionsValue = role.Permissions.GetRawValue();

            var guild = await _restClient.GetGuildAsync(discordServer.Id);

            var createRoleTask = guild.CreateRoleAsync(role.Name, new GuildPermissions(permissionsValue));

            var restRole = createRoleTask.Result;
            var userRole = new UserRoleFactory().Create(restRole);

            return(userRole);
        }
예제 #8
0
        //G_Role
        public ACGroupingAccountController()
        {
            _ROfactory       = new RoleOrganizationFactory();
            _RoSfactory      = new RoleOnStoreFactory();
            _MPfactory       = new ModulePermissionFactory();
            _UserRoleFactory = new UserRoleFactory();
            _Empfactory      = new EmployeeFactory();
            if (!string.IsNullOrEmpty(CurrentUser.OrganizationName))
            {
                List <SelectListItem> listOrganization = new List <SelectListItem>();
                listOrganization.Add(new SelectListItem()
                {
                    Value = CurrentUser.ListOrganizationId[0].ToString(),
                    Text  = CurrentUser.OrganizationName
                });
                ViewBag.ListOrganization = listOrganization;
            }
            ViewBag.ListStore = GetListStore();
            var ListCompanyStore = GetListStoreRole();

            lstStore = ViewBag.ListStore;
            //=================
            var listCompany = ListCompanyStore.GroupBy(x => x.CompanyId).Select(x => x.FirstOrDefault());

            foreach (var item in listCompany)
            {
                var         listStore = ListCompanyStore.Where(x => x.CompanyId.Equals(item.CompanyId)).ToList();
                CompanyItem company   = new CompanyItem();
                company.CompanyId   = item.CompanyId;
                company.CompanyName = item.CompanyName;
                foreach (var itemStore in listStore)
                {
                    company.ListStore.Add(new StoreItem
                    {
                        StoreId   = itemStore.Id,
                        StoreName = itemStore.Name
                    });
                }
                lstCompany.Add(company);
            }
        }
        public async Task <IActionResult> Login([FromForm] ApplicationUser _user)
        {
            if (ModelState.IsValid)
            {
                var user = await _unitOfWork.PhysicalPerson.GetByEmail(_user.Email);

                if (user != null)
                {
                    var salt   = _hasher.CreateSalt();
                    var result = _hasher.VerifyHash(_user.ProvidedPassword, salt, user.PasswordHash);

                    if (result)
                    {
                        var userClaims = new List <Claim>()
                        {
                            //define o cookie
                            new Claim(ClaimTypes.Name, user.UserName),
                            new Claim(ClaimTypes.Email, user.Email),
                            new Claim(ClaimTypes.Role, UserRoleFactory.Role(user.Role)),
                        };
                        var minhaIdentity = new ClaimsIdentity(userClaims, "Usuario");
                        var userPrincipal = new ClaimsPrincipal(new[] { minhaIdentity });
                        //cria o cookie
                        await HttpContext.SignInAsync(userPrincipal);

                        return(RedirectToAction("Index", "Home"));
                    }

                    ViewBag.Message = "Senha incorreta";
                    return(View());
                }
                else
                {
                    ViewBag.Message = "Usuário não encontrado";
                    return(View());
                }
            }

            return(View());
        }
예제 #10
0
        public ResultModels LoginOnDevice(string email, string pwd, string langId, bool isNuPos)
        {
            NSLog.Logger.Info("LoginOnDevice Start:", "Email: " + email
                              + "Password: "******"LangId: " + langId
                              + "IsNuPos: " + isNuPos);


            ResultModels result = new ResultModels();

            UserFactory     factoy           = new UserFactory();
            UserRoleFactory _UserRoleFactory = new UserRoleFactory();
            LanguageFactory _LanguageFactory = new LanguageFactory();

            //=========
            LoginModel model   = new LoginModel();
            UserModels User    = factoy.IsCheckLogin(email, pwd, true);
            bool       isValid = (User != null);

            if (isValid)
            {
                UserModule roles = null;
                if (!User.IsSuperAdmin)
                {
                    roles = _UserRoleFactory.CheckModuleForEmp(User.UserId, User.ListOrganizationId[0]);
                    if (roles == null || string.IsNullOrEmpty(roles.Controller))
                    {
                        result.Message = "Email is not authorized to login";
                        NSLog.Logger.Info("LoginOnDevice Result:", result);
                        return(result);
                    }
                }

                if (User.IsSuperAdmin)
                {
                    model.ListStoreID = User.ListStoreID;
                }
                else
                {
                    model.ListStoreID = _UserRoleFactory.GetStoreEmpAccess(User.UserId);
                }

                //End Check Role of Account
                //Check merchant extend here
                UserSession userSession = new UserSession();
                userSession.ListMerchantExtends = factoy.GetListMerchantExtend(userSession.EmployeeConfigId);
                if (userSession.ListMerchantExtends != null && userSession.ListMerchantExtends.Count > 0)
                {
                    userSession.IsMerchantExtend = true;
                    var lstStoreExtend = (from p in userSession.ListMerchantExtends
                                          where p.ListStoreIds.Any()
                                          select p)
                                         .SelectMany(p => p.ListStoreIds).ToList();

                    model.ListStoreID.AddRange(lstStoreExtend);
                }
                //End check merchant extend here

                //UserSession userSession = new UserSession();
                userSession.Email           = User.Email;
                userSession.UserName        = User.Name;
                userSession.UserId          = User.UserId;
                userSession.UserType        = 0;
                userSession.IsAuthenticated = true;
                userSession.ImageUrl        = null;
                if (!string.IsNullOrEmpty(User.ImageURL))
                {
                    userSession.ImageUrl = User.ImageURL;
                }
                userSession.IndustryId   = "";// model.IndustryId;
                userSession.ListIndustry = User.ListIndustry;

                userSession.ListOrganizationId = User.ListOrganizationId;
                userSession.IsSuperAdmin       = User.IsSuperAdmin;
                userSession.OrganizationName   = User.OrganizationName;

                userSession.listStore = User.listStore;

                //if (User.IsSuperAdmin)
                //    model.ListStoreID = User.ListStoreID;
                //else
                //    model.ListStoreID = _UserRoleFactory.GetStoreEmpAccess(User.UserId);

                userSession.ListStoreID = model.ListStoreID;
                if (model.ListStoreID.Count == 1)
                {
                    userSession.StoreId = model.ListStoreID[0];
                }
                model.StoreName = User.StoreName;

                userSession.IndustryId = "HQForFnB";
                userSession.AppKey     = User.AppKey;
                userSession.AppSecret  = User.AppSecret;
                userSession.LanguageId = langId;// model.LanguageId;
                /*Get List Key Language*/

                var lstLangData = _LanguageFactory.GetLanguageDataToTrans(langId /*model.LanguageId*/);
                //var a = _LanguageFactory.GetLanguageDataToTranslateForLogin(model.LanguageId);
                //var lstLangData = _LanguageFactory.GetListLanguageForText(model.LanguageId);
                foreach (var item in lstLangData)
                {
                    if (!userSession.ListLanguageText.ContainsKey(item.LanguageLinkName))
                    {
                        userSession.ListLanguageText.Add(item.LanguageLinkName, item.Text);
                    }
                }
                userSession.RememberMe = true;   // model.RememberMe;
                Commons._RememberMe    = true;   // model.RememberMe;
                Commons._LanguageId    = langId; // model.LanguageId;

                ////=====End Get Language For DateTimePicker
                userSession.ListSetting = User.ListSetting;

                //update 18/12/2017

                //// end update 18/12/2017
                //userSession.WebUrlHost = "http://api.nupos.com.sg/nuweb";

                System.Web.HttpContext.Current.Session.Add("User", userSession);
                //NSLog.Logger.Info("Check Return URL", returnUrl);
                //if (returnUrl == null)
                //    return RedirectToAction("Index", "Home", new { area = "" });
                //else
                //    return Redirect(returnUrl);

                result.IsOk    = true;
                result.Message = "OK";
                NSLog.Logger.Info("LoginOnDevice Result:", result);
            }
            return(result);
        }
예제 #11
0
        public ResultModels LoginExtend(LoginModel model)
        {
            ResultModels result = new ResultModels();

            result.IsOk = true;
            UserRoleFactory _UserRoleFactory = new UserRoleFactory();
            LanguageFactory _LanguageFactory = new LanguageFactory();
            bool            isExistUser      = false;
            UserFactory     factoy           = new UserFactory();
            UserSession     userSession      = new UserSession();

            GetValueCommons(model.Email, model.Password, model.IsFormOtherLink, ref isExistUser, ref userSession);
            if (isExistUser)
            {
                UserModels User    = factoy.IsCheckLogin(model.Email, model.Password, false);
                bool       isValid = (User != null);
                if (isValid)
                {
                    UserModule roles = null;
                    if (!User.IsSuperAdmin)
                    {
                        roles = _UserRoleFactory.CheckModuleForEmp(User.UserId, User.ListOrganizationId[0]);
                        if (roles == null || string.IsNullOrEmpty(roles.Controller))
                        {
                            result.Message = "Email is not authorized to login";
                        }
                    }

                    if (User.IsSuperAdmin)
                    {
                        model.ListStoreID = User.ListStoreID;
                    }
                    else
                    {
                        model.ListStoreID = _UserRoleFactory.GetStoreEmpAccess(User.UserId);
                    }

                    //End Check Role of Account
                    //Check merchant extend here
                    userSession.ListMerchantExtends = factoy.GetListMerchantExtend(userSession.EmployeeConfigId);
                    if (userSession.ListMerchantExtends != null && userSession.ListMerchantExtends.Count > 0)
                    {
                        userSession.IsMerchantExtend = true;
                        var lstStoreExtend = (from p in userSession.ListMerchantExtends
                                              where p.ListStoreIds.Any()
                                              select p)
                                             .SelectMany(p => p.ListStoreIds).ToList();

                        model.ListStoreID.AddRange(lstStoreExtend);
                    }
                    //End check merchant extend here
                    //UserSession userSession = new UserSession();
                    userSession.Email           = User.Email;
                    userSession.UserName        = User.Name;
                    userSession.UserId          = User.UserId;
                    userSession.UserType        = 0;
                    userSession.IsAuthenticated = true;
                    userSession.ImageUrl        = null;
                    if (!string.IsNullOrEmpty(User.ImageURL))
                    {
                        userSession.ImageUrl = User.ImageURL;
                    }
                    userSession.IndustryId   = model.IndustryId;
                    userSession.ListIndustry = User.ListIndustry;

                    userSession.ListOrganizationId = User.ListOrganizationId;
                    userSession.IsSuperAdmin       = User.IsSuperAdmin;
                    userSession.OrganizationName   = User.OrganizationName;

                    userSession.listStore = User.listStore;


                    userSession.ListStoreID = model.ListStoreID;
                    if (model.ListStoreID.Count == 1)
                    {
                        userSession.StoreId = model.ListStoreID[0];
                    }
                    model.StoreName = User.StoreName;

                    userSession.IndustryId = "HQForFnB";
                    userSession.AppKey     = User.AppKey;
                    userSession.AppSecret  = User.AppSecret;
                    userSession.LanguageId = model.LanguageId;
                    /*Get List Key Language*/

                    var lstLangData = _LanguageFactory.GetLanguageDataToTrans(model.LanguageId);
                    foreach (var item in lstLangData)
                    {
                        if (!userSession.ListLanguageText.ContainsKey(item.LanguageLinkName))
                        {
                            userSession.ListLanguageText.Add(item.LanguageLinkName, item.Text);
                        }
                    }
                    userSession.RememberMe = model.RememberMe;

                    Commons._RememberMe = model.RememberMe;
                    if (model.RememberMe)
                    {
                        Commons._LanguageId = model.LanguageId;
                    }
                    ////=====End Get Language For DateTimePicker
                    userSession.ListSetting = User.ListSetting;

                    //update 18/12/2017
                    //check location
                    //var countryCode = _baseFactory.GetCountryCode();
                    //get setting from db
                    // end update 18/12/2017
                    //userSession.WebUrlHost = "http://api.nupos.com.sg/nuweb";

                    System.Web.HttpContext.Current.Session.Add("User", userSession);
                }
                else
                {
                    result.Message = "Email/Password is incorrect!";
                    result.IsOk    = false;
                    //model.ListLanguage = _LanguageFactory.GetListLang(ref model);
                }
            }
            else
            {
                result.Message = "Email/Password is incorrect!";
                result.IsOk    = false;
            }
            return(result);
        }
        public IEnumerable <UserRole> GetRoles(ulong guildId)
        {
            var roleFactory = new UserRoleFactory();

            return(this.GetSocketRoles(guildId).Select(x => roleFactory.Create(x)));
        }
예제 #13
0
        public async Task AddAsync(UserRoleModel model)
        {
            await _repository.AddAsync(UserRoleFactory.Create(model, _userId));

            await _unitOfWork.SaveChangesAsync();
        }
예제 #14
0
 public NuAuthAttribute()
 {
     _UserRoleFactory = new UserRoleFactory();
 }