mirror of
https://github.com/System-End/spaces.git
synced 2026-04-19 16:38:24 +00:00
fix login and space creation
This commit is contained in:
parent
f2b990dbf7
commit
a4815f03a1
4 changed files with 14 additions and 12 deletions
|
|
@ -5,6 +5,7 @@
|
|||
const dispatch = createEventDispatcher();
|
||||
|
||||
let mode = 'login';
|
||||
let authIntent = 'login'; // Track original intent (login/signup) even when in verify mode
|
||||
let email = '';
|
||||
let username = '';
|
||||
let verificationCode = '';
|
||||
|
|
@ -108,6 +109,7 @@
|
|||
error = '';
|
||||
message = '';
|
||||
verificationCode = '';
|
||||
authIntent = newMode; // Update the auth intent
|
||||
setTimeout(() => {
|
||||
mode = newMode;
|
||||
}, 400);
|
||||
|
|
@ -184,7 +186,7 @@
|
|||
{:else if mode === 'verify'}
|
||||
<p class="info-message">Check your email for the verification code</p>
|
||||
|
||||
<form on:submit|preventDefault={mode === 'login' ? handleLogin : handleSignup}>
|
||||
<form on:submit|preventDefault={authIntent === 'login' ? handleLogin : handleSignup}>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="code">Verification Code</label>
|
||||
<input
|
||||
|
|
@ -202,7 +204,7 @@
|
|||
{/if}
|
||||
|
||||
<button class="primary-button" type="submit" disabled={loading || !verificationCode}>
|
||||
{loading ? 'Verifying...' : mode === 'signup' ? 'Complete Sign Up' : 'Login'}
|
||||
{loading ? 'Verifying...' : authIntent === 'signup' ? 'Complete Sign Up' : 'Login'}
|
||||
</button>
|
||||
|
||||
<button class="secondary-button" type="button" on:click={() => switchMode(mode)}>
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@ http {
|
|||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# Port forwarding - matches /port/8080, /port/3001, etc.
|
||||
# Port forwarding - matches /space/8080, /space/3001, etc.
|
||||
# Routes to localhost ports (containers running in Docker-in-Docker)
|
||||
location ~ ^/port/(\d+)(/.*)?$ {
|
||||
location ~ ^/space/(\d+)(/.*)?$ {
|
||||
set $port $1;
|
||||
set $path $2;
|
||||
set $target localhost:$port;
|
||||
set $target 127.0.0.1:$port;
|
||||
proxy_pass http://$target$path;
|
||||
proxy_set_header Host localhost:$port;
|
||||
proxy_set_header Host localhost;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
|
|
|||
|
|
@ -144,9 +144,9 @@ router.post('/signup', async (req, res) => {
|
|||
// POST /api/v1/users/login
|
||||
router.post('/login', async (req, res) => {
|
||||
try {
|
||||
const { email, code } = req.body;
|
||||
const { email, verificationCode } = req.body;
|
||||
|
||||
if (!email || !code) {
|
||||
if (!email || !verificationCode) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: 'Email and verification code are required'
|
||||
|
|
@ -161,7 +161,7 @@ router.post('/login', async (req, res) => {
|
|||
});
|
||||
}
|
||||
|
||||
const codeValid = await checkEmail(email, code);
|
||||
const codeValid = await checkEmail(email, verificationCode);
|
||||
if (!codeValid) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
|
|
|
|||
|
|
@ -73,12 +73,12 @@ export const createContainer = async (password, type, authorization) => {
|
|||
description: config.description,
|
||||
image: config.image,
|
||||
port,
|
||||
access_url: `${process.env.SERVER_URL}/port/${port}`
|
||||
access_url: `${process.env.SERVER_URL}/space/${port}/`
|
||||
})
|
||||
.returning(['id', 'container_id', 'type', 'description', 'image', 'port', 'access_url']);
|
||||
|
||||
if (process.env.DOCKER === 'true') {
|
||||
newSpace.access_url = `http://${process.env.SERVER_URL}/ports/${newSpace.port}`;
|
||||
if (process.env.DOCKER === 'false') {
|
||||
newSpace.access_url = `http://${process.env.SERVER_URL}:${newSpace.port}`;
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue