Esempio n. 1
0
 /**
  * Load an app by ID if it has not been loaded yet
  *
  * @param string appId
  */
 protected void loadTwoFactorApp(string appId)
 {
     if (!OC_App.isAppLoaded(appId))
     {
         OC_App.loadApp(appId);
     }
 }
Esempio n. 2
0
        /**
         * Get the directory for the given app.
         *
         * @param string appId
         * @return string
         * @throws AppPathNotFoundException if app folder can"t be found
         */
        public string getAppPath(string appId)
        {
            var appPath = OC_App.getAppPath(appId);

            if (appPath.IsEmpty())
            {
                throw new AppPathNotFoundException("Could not find path for " + appId);
            }

            return(appPath);
        }
Esempio n. 3
0
        /**
         * Returns a list of apps that need upgrade
         *
         * @param string version Nextcloud version as array of version components
         * @return array list of app info from apps that need an upgrade
         *
         * @internal
         */
        public IList getAppsNeedingUpgrade(string version)
        {
            var appsToUpgrade = new List <AppInfo>();
            var apps          = this.getInstalledApps();

            foreach (var appId in apps)
            {
                var appInfo      = this.getAppInfo(appId);
                var appDbVersion = this.appConfig.getValue(appId, "installed_version");
                if (appDbVersion.IsNotEmpty() &&
                    appInfo.Version.IsNotEmpty() &&
                    VersionUtility.version_compare(appInfo.Version, appDbVersion, ">") &&
                    OC_App.isAppCompatible(version, appInfo)
                    )
                {
                    appsToUpgrade.Add(appInfo);
                }
            }

            return(appsToUpgrade);
        }
Esempio n. 4
0
        /**
         * Returns a list of apps incompatible with the given version
         *
         * @param string version Nextcloud version as array of version components
         *
         * @return array list of app info from incompatible apps
         *
         * @internal
         */
        public IList <AppInfo> getIncompatibleApps(string version)
        {
            var apps             = this.getInstalledApps();
            var incompatibleApps = new List <AppInfo>();

            foreach (var appId in apps)
            {
                var info = this.getAppInfo(appId);
                if (info == null)
                {
                    info = new AppInfo()
                    {
                        Id = appId
                    };
                    incompatibleApps.Add(info);
                }
                else if (!OC_App.isAppCompatible(version, info))
                {
                    incompatibleApps.Add(info);
                }
            }

            return(incompatibleApps);
        }
Esempio n. 5
0
        /**
         * @PublicPage
         * @NoCSRFRequired
         * @UseSession
         *
         * @param string user
         * @param string redirect_url
         *
         * @return TemplateResponse|RedirectResponse
         */
        public Response showLoginForm(string user = null, string redirect_url = null)
        {
            if (this.userSession.isLoggedIn())
            {
                return(new RedirectResponse(OC_Util.getDefaultPageUrl()));
            }

            var loginMessages = this.session.get("loginMessages");

            if (loginMessages is IList)
            {
                var errors   = ((IList)loginMessages)[0];
                var messages = ((IList)loginMessages)[1];
                this.initialStateService.provideInitialState("core", "loginMessages", messages);
                this.initialStateService.provideInitialState("core", "loginErrors", errors);
            }

            this.session.remove("loginMessages");

            if (!string.IsNullOrEmpty(user))
            {
                this.initialStateService.provideInitialState("core", "loginUsername", user);
            }
            else
            {
                this.initialStateService.provideInitialState("core", "loginUsername", "");
            }

            this.initialStateService.provideInitialState(
                "core",
                "loginAutocomplete",
                this.config.getSystemValue("login_form_autocomplete", true)
                );

            if (redirect_url.IsNotEmpty())
            {
                this.initialStateService.provideInitialState("core", "loginRedirectUrl", redirect_url);
            }

            this.initialStateService.provideInitialState(
                "core",
                "loginThrottleDelay",
                this.throttler.getDelay(this.request.getRemoteAddress())
                );

            this.setPasswordResetInitialState(user);

            // OpenGraph Support: http://ogp.me/
            Util.addHeader("meta", new Dictionary <string, object>()
            {
                { "property", "og:title" },
                { "content", Util.sanitizeHTML(this.defaults.getName()) }
            });
            Util.addHeader("meta", new Dictionary <string, object>()
            {
                { "property", "og:description" },
                { "content", Util.sanitizeHTML(this.defaults.getSlogan()) }
            });
            Util.addHeader("meta", new Dictionary <string, object>()
            {
                { "property", "og:site_name" },
                { "content", Util.sanitizeHTML(this.defaults.getName()) }
            });
            Util.addHeader("meta", new Dictionary <string, object>()
            {
                { "property", "og:url" },
                { "content", this.urlGenerator.getAbsoluteURL("/") }
            });
            Util.addHeader("meta", new Dictionary <string, object>()
            {
                { "property", "og:type" },
                { "content", "website" }
            });
            Util.addHeader("meta", new Dictionary <string, object>()
            {
                { "property", "og:image" },
                { "content", this.urlGenerator.getAbsoluteURL(this.urlGenerator.imagePath("core", "favicon-touch.png")) }
            });


            var parameters = new Dictionary <string, object>
            {
                { "alt_login", OC_App.getAlternativeLogIns() }
            };

            return(new TemplateResponse(
                       this.appName, "login", parameters, "guest"
                       ));
        }