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;
        }
 public static void DeleteFtpAccount(FtpAccount ftpAccount)
 {
     var identity = HttpContext.Current.User.Identity;
     if (identity.IsAuthenticated)
     {
         var accountManager = new AccountManager();
         accountManager.DeleteFtpAccount(ftpAccount.Username);
     }
 }
        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("~/");
            }
        }
        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);
            }
        }
        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>();
        }
Example #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"
                });
            }
        }