예제 #1
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="controller"></param>
        public SettingsModel(ControllerBase controller) : base(controller)
        {
            Themes         = DictHelper.RetrieveThemes();
            AutoLockScreen = EnableAutoLockScreen;
            DefaultApp     = DictHelper.RetrieveDefaultApp();
            IPLocators     = DictHelper.RetireveLocators();
            IPLocatorSvr   = DictHelper.RetrieveLocaleIPSvr();
            ErrorLogPeriod = DictHelper.RetrieveExceptionsLogPeriod();
            OpLog          = DictHelper.RetrieveLogsPeriod();
            LogLog         = DictHelper.RetrieveLoginLogsPeriod();
            TraceLog       = DictHelper.RetrieveAccessLogPeriod();
            CookiePeriod   = DictHelper.RetrieveCookieExpiresPeriod();
            IPCachePeriod  = DictHelper.RetrieveLocaleIPSvrCachePeriod();
            EnableDemo     = DictHelper.RetrieveSystemModel();
            AdminPathBase  = DictHelper.RetrievePathBase();
            EnableHealth   = DictHelper.RetrieveHealth();
            Logins         = DictHelper.RetrieveLogins();
            var view     = DictHelper.RetrieveLoginView();
            var viewName = Logins.FirstOrDefault(d => d.Code == view)?.Name ?? "系统默认";

            LoginView = new KeyValuePair <string, string>(view, viewName);

            var dicts = DictHelper.RetrieveDicts();

            Apps = DictHelper.RetrieveApps().Where(d => !d.Key.Equals("BA", StringComparison.OrdinalIgnoreCase)).Select(k =>
            {
                var url = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name == k.Key && d.Define == 0)?.Code ?? "未设置";
                return(k.Key, k.Value, url);
            });
        }
예제 #2
0
 public CreateDatabaseUser(IDatabaseUserAccessService databaseUserAccessService, IServerUserAccessService serverUserAccessService, string database)
 {
     _databaseUserAccessService = databaseUserAccessService;
     _database = database;
     Logins    = serverUserAccessService.GetLoginsName();
     Login     = Logins.FirstOrDefault();
     InitializeComponent();
 }
예제 #3
0
        public virtual bool RemoveLogin(UserLoginInfo info)
        {
            if (!HasLogin(info))
            {
                return(false);
            }

            var existing =
                Logins.FirstOrDefault(x => x.ProviderKey == info.ProviderKey && x.LoginProvider == info.LoginProvider);

            Logins.Remove(existing);

            return(true);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="loginProvider"></param>
        /// <param name="providerKey"></param>
        /// <returns></returns>
        public virtual IdentityUserLogin <TKey> GetUserLogin(string loginProvider, string providerKey)
        {
            var login = Logins.FirstOrDefault(e => e.LoginProvider == loginProvider && e.ProviderKey == providerKey);

            if (login != null)
            {
                return(new IdentityUserLogin <TKey>
                {
                    UserId = Id,
                    LoginProvider = login.LoginProvider,
                    ProviderDisplayName = login.ProviderDisplayName,
                    ProviderKey = login.ProviderKey
                });
            }
            return(default);
예제 #5
0
        /// <summary>
        /// Removes a <see cref="UserLoginInfo"/> from the user.
        /// </summary>
        /// <param name="userLoginInfo"></param>
        public virtual bool RemoveLogin(UserLoginInfo userLoginInfo)
        {
            if (userLoginInfo == null)
            {
                throw new ArgumentNullException(nameof(userLoginInfo));
            }
            var loginToRemove = Logins.FirstOrDefault(e => e.LoginProvider == userLoginInfo.LoginProvider);

            if (loginToRemove == null)
            {
                return(false);
            }
            Logins.Remove(loginToRemove);
            return(true);
        }
예제 #6
0
        public Login()
        {
            initialize();
            OnRetryLoginCommand    = new DelegateCommand(OnRetryLoginCommandExecute);
            OnLoginCommand         = new DelegateCommand(OnLoginCommandExecute);
            OnPasswordKeyUpCommand = new DelegateCommand <KeyEventArgs>(OnPasswordKeyUpCommandExecuted);

            Account = Logins.FirstOrDefault();
            Server  = Servers.FirstOrDefault();
#if (DEBUG)
            /*Password = "******";
             * Server = "localhost";*/
#endif
            SetFocusTo();
        }
예제 #7
0
        /// <summary>
        /// Add new login
        /// </summary>
        /// <param name="login">user's login</param>
        /// <returns>ok</returns>
        public async Task AddLogin(Logins login)
        {
            Logins existed = Logins.FirstOrDefault(x => x.Login == login.Login);

            if (existed == null)
            {
                var role = Roles.LastOrDefault(x => x.Id > 0);
                if (role != null)
                {
                    login.RoleId = role.Id;
                }

                await Logins.AddAsync(login);
                await SaveChangesAsync();
            }
        }
예제 #8
0
        /// <summary>
        /// Add new user's userData
        /// </summary>
        /// <param name="usersData">user's userData</param>
        /// <returns>ok</returns>
        public async Task AddUserData(UsersData usersData)
        {
            UsersData existed = UsersData.FirstOrDefault(x => x.Email == usersData.Email);

            if (existed == null)
            {
                var login = Logins.FirstOrDefault(x => x.Login == usersData.Email);
                if (login != null)
                {
                    usersData.Id = login.Id;
                }

                await UsersData.AddAsync(usersData);
                await SaveChangesAsync();
            }
        }
예제 #9
0
        /// <summary>
        /// Change role for user
        /// </summary>
        /// <param name="roles">new role</param>
        /// <returns>login with new role</returns>
        public async Task <Logins> ChangeRole(Roles roles)
        {
            Logins existed = Logins.FirstOrDefault(x => x.RoleId == roles.Id);

            if (existed != null)
            {
                var current = Roles.FirstOrDefault(x => x.Id == existed.RoleId);
                if (current != null)
                {
                    current.Title = roles.Title;
                }

                await SaveChangesAsync();
            }

            return(existed);
        }