Skip to content

Commit ad7b7b9

Browse files
committed
fix: don't show register when user signup is disabled
closes #1087
1 parent 76bedf5 commit ad7b7b9

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/backend/src/services/PuterHomepageService.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
const { PathBuilder } = require("../util/pathutil");
2121
const BaseService = require("./BaseService");
2222
const {is_valid_url} = require('../helpers');
23+
const { Endpoint } = require("../util/expressutil");
2324

2425
/**
2526
* PuterHomepageService serves the initial HTML page that loads the Puter GUI
@@ -66,6 +67,20 @@ class PuterHomepageService extends BaseService {
6667
}
6768

6869

70+
async ['__on_install.routes'] (_, { app }) {
71+
Endpoint({
72+
route: '/whoarewe',
73+
methods: ['GET'],
74+
handler: async (req, res) => {
75+
res.json({
76+
disable_user_signup: this.global_config.disable_user_signup,
77+
disable_temp_users: this.global_config.disable_temp_users,
78+
});
79+
}
80+
}).attach(app);
81+
}
82+
83+
6984
/**
7085
* This method sends the initial HTML page that loads the Puter GUI and its assets.
7186
*/

src/gui/src/UI/UIWindowLogin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ async function UIWindowLogin(options){
7070
h += `</form>`;
7171
h += `</div>`;
7272
// create account link
73+
74+
// If show_signup_button is undefined, the default behavior is to show it.
75+
// If show_signup_button is set to false, the button will not be shown.
7376
if(options.show_signup_button === undefined || options.show_signup_button){
7477
h += `<div class="c2a-wrapper" style="padding:20px;">`;
7578
h += `<button class="signup-c2a-clickable">${i18n('create_free_account')}</button>`;

src/gui/src/initgui.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,9 +790,13 @@ window.initgui = async function(options){
790790
UIWindowSessionList();
791791
}
792792
else{
793+
const resp = await fetch(puter.defaultGUIOrigin + '/whoarewe');
794+
const whoarewe = await resp.json();
793795
await UIWindowLogin({
796+
// show_signup_button:
794797
reload_on_success: true,
795798
send_confirmation_code: false,
799+
show_signup_button: ( ! whoarewe.disable_user_signup ),
796800
window_options:{
797801
has_head: false
798802
}

0 commit comments

Comments
 (0)