Ejemplo n.º 1
0
        public IFileSystem Create(string sUser, string sPassword)
        {
            string containerName = "";

            // TODO: Put your authentication call here. Return NULL if authentication fails. Return an initialised AzureFileSystem() object if authentication is successful.
            // In the example below, to demonstrate, any username will work so long as the password == "test".
            // Remember: you can plug in your own authentication & authorisation API to fetch the correct container name for the specified user.
            /*
            #region "REPLACE THIS WITH CODE TO YOUR OWN AUTHENTICATION API"
            if (sPassword == "test")
            {
                containerName = sUser;
            }
            else
            {
                return null;
            }
            #endregion  */

            var accountManager = new AccountManager();
            if (accountManager.CertificateAccount(sUser, sPassword))
                containerName = sUser;
            else
                return null;

            var system = new AzureFileSystem(sUser, sPassword, containerName, Modes.Development);
            return system;
        }
Ejemplo n.º 2
0
 public static void DeleteFtpAccount(FtpAccount ftpAccount)
 {
     var identity = HttpContext.Current.User.Identity;
     if (identity.IsAuthenticated)
     {
         var accountManager = new AccountManager();
         accountManager.DeleteFtpAccount(ftpAccount.Username);
     }
 }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var identity = HttpContext.Current.User.Identity;
            if (identity.IsAuthenticated)
            {
                var accountManager = new AccountManager();
                bool isSuperUser = identity.Name.ToLower() == AccountManager.AdminUserName
                    || accountManager.IsSuperUser(identity.Name);

                if (!isSuperUser)
                    Response.Redirect("~/");
            }
        }
Ejemplo n.º 4
0
        public static void UpdateFtpAccount(FtpAccount ftpAccount)
        {
            var identity = HttpContext.Current.User.Identity;
            if (identity.IsAuthenticated)
            {
                var accountManager = new AccountManager();

                string Username = ftpAccount.Username;
                bool isActive = ftpAccount.IsActive;
                bool isSuperUser = identity.Name.ToLower() == AccountManager.AdminUserName ?
                    ftpAccount.IsSuperUser : false;

                accountManager.UpdateFtpAccount(Username, isSuperUser, isActive);
            }
        }
Ejemplo n.º 5
0
        public static List<FtpAccount> GetAllFtpAccount()
        {
            var identity = HttpContext.Current.User.Identity;
            if (identity.IsAuthenticated)
            {
                bool filterSuperUser = identity.Name.ToLower() != AccountManager.AdminUserName;
                var accountManager = new AccountManager();

                if (!accountManager.IsSuperUser(identity.Name))
                    return new List<FtpAccount>();

                return accountManager.QueryAllFtpAccount(filterSuperUser);
            }

            return new List<FtpAccount>();
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool isSuperUser = false;

            var identity = HttpContext.Current.User.Identity;
            if (identity.IsAuthenticated)
            {
                var accountManager = new AccountManager();
                isSuperUser = accountManager.IsSuperUser(identity.Name);
            }

            if (isSuperUser)
            {
                NavigationMenu.Items.Add(new MenuItem() {
                    Text = "管理用户",
                    NavigateUrl = "~/UserManagement.aspx"
                });
            }
        }