Merge pull request #2662 from ItzYanick/feature/registrationDisabled

impl registrationDisabled into NavBar
This commit is contained in:
Kavin 2023-07-14 04:49:56 +01:00 committed by GitHub
commit f0d7ffb785
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,7 +44,7 @@
<li v-if="shouldShowLogin"> <li v-if="shouldShowLogin">
<router-link v-t="'titles.login'" to="/login" /> <router-link v-t="'titles.login'" to="/login" />
</li> </li>
<li v-if="shouldShowLogin"> <li v-if="shouldShowRegister">
<router-link v-t="'titles.register'" to="/register" /> <router-link v-t="'titles.register'" to="/register" />
</li> </li>
<li v-if="shouldShowHistory"> <li v-if="shouldShowHistory">
@ -129,9 +129,11 @@ export default {
suggestionsVisible: false, suggestionsVisible: false,
showTopNav: false, showTopNav: false,
homePagePath: "/", homePagePath: "/",
registrationDisabled: false,
}; };
}, },
mounted() { mounted() {
this.fetchAuthConfig();
const query = new URLSearchParams(window.location.search).get("search_query"); const query = new URLSearchParams(window.location.search).get("search_query");
if (query) this.onSearchTextChange(query); if (query) this.onSearchTextChange(query);
this.focusOnSearchBar(); this.focusOnSearchBar();
@ -141,6 +143,9 @@ export default {
shouldShowLogin(_this) { shouldShowLogin(_this) {
return _this.getAuthToken() == null; return _this.getAuthToken() == null;
}, },
shouldShowRegister(_this) {
return _this.registrationDisabled == false ? _this.shouldShowLogin : false;
},
shouldShowHistory(_this) { shouldShowHistory(_this) {
return _this.getPreferenceBoolean("watchHistory", false); return _this.getPreferenceBoolean("watchHistory", false);
}, },
@ -185,6 +190,11 @@ export default {
onSearchTextChange(searchText) { onSearchTextChange(searchText) {
this.searchText = searchText; this.searchText = searchText;
}, },
async fetchAuthConfig() {
this.fetchJson(this.authApiUrl() + "/config").then(config => {
this.registrationDisabled = config?.registrationDisabled === true;
});
},
}, },
}; };
</script> </script>