fix: don't show register when user signup is disabled

closes #1087
This commit is contained in:
KernelDeimos
2025-03-12 14:52:23 -04:00
parent 76bedf5f8f
commit ad7b7b9513
3 changed files with 22 additions and 0 deletions

View File

@@ -20,6 +20,7 @@
const { PathBuilder } = require("../util/pathutil");
const BaseService = require("./BaseService");
const {is_valid_url} = require('../helpers');
const { Endpoint } = require("../util/expressutil");
/**
* PuterHomepageService serves the initial HTML page that loads the Puter GUI
@@ -66,6 +67,20 @@ class PuterHomepageService extends BaseService {
}
async ['__on_install.routes'] (_, { app }) {
Endpoint({
route: '/whoarewe',
methods: ['GET'],
handler: async (req, res) => {
res.json({
disable_user_signup: this.global_config.disable_user_signup,
disable_temp_users: this.global_config.disable_temp_users,
});
}
}).attach(app);
}
/**
* This method sends the initial HTML page that loads the Puter GUI and its assets.
*/

View File

@@ -70,6 +70,9 @@ async function UIWindowLogin(options){
h += `</form>`;
h += `</div>`;
// create account link
// If show_signup_button is undefined, the default behavior is to show it.
// If show_signup_button is set to false, the button will not be shown.
if(options.show_signup_button === undefined || options.show_signup_button){
h += `<div class="c2a-wrapper" style="padding:20px;">`;
h += `<button class="signup-c2a-clickable">${i18n('create_free_account')}</button>`;

View File

@@ -790,9 +790,13 @@ window.initgui = async function(options){
UIWindowSessionList();
}
else{
const resp = await fetch(puter.defaultGUIOrigin + '/whoarewe');
const whoarewe = await resp.json();
await UIWindowLogin({
// show_signup_button:
reload_on_success: true,
send_confirmation_code: false,
show_signup_button: ( ! whoarewe.disable_user_signup ),
window_options:{
has_head: false
}