fix: show login result after redirect to home view
This commit is contained in:
1 parent
ed1f741a9e
commit
c7a990e3fe
1 file changed
+43
-26
+43
-26
@@ -40,6 +40,7 @@
|
|||||||
} from '@/osuUtil';
|
} from '@/osuUtil';
|
||||||
import { git } from '@/api/git';
|
import { git } from '@/api/git';
|
||||||
import { sileo } from 'sileo';
|
import { sileo } from 'sileo';
|
||||||
|
import type { EZPPUser } from '@/types';
|
||||||
|
|
||||||
let ezppLogo: HTMLImageElement;
|
let ezppLogo: HTMLImageElement;
|
||||||
let spinnerCircle: SVGCircleElement;
|
let spinnerCircle: SVGCircleElement;
|
||||||
@@ -84,40 +85,32 @@
|
|||||||
|
|
||||||
const username = $userAuth.value('username').get('');
|
const username = $userAuth.value('username').get('');
|
||||||
const password = $userAuth.value('password').get('');
|
const password = $userAuth.value('password').get('');
|
||||||
if (username.length > 0 && password.length > 0) {
|
|
||||||
|
const shouldLogin = username.length > 0 && password.length > 0;
|
||||||
|
let userLoginResult: { message: string; user?: EZPPUser } = {
|
||||||
|
message: 'An unknown error occured!',
|
||||||
|
};
|
||||||
|
|
||||||
|
if (shouldLogin) {
|
||||||
currentLoadingInfo.set('Logging in...');
|
currentLoadingInfo.set('Logging in...');
|
||||||
try {
|
try {
|
||||||
const loginResult = await ezppfarm.login(username, password);
|
const loginResult = await ezppfarm.login(username, password);
|
||||||
if (loginResult && loginResult.user) {
|
if (loginResult && loginResult.user) {
|
||||||
sileo.success({
|
userLoginResult = {
|
||||||
title: 'Login successful!',
|
message: `Welcome back, ${loginResult.user.name}!`,
|
||||||
description: `Welcome back, ${loginResult.user.name}!`,
|
user: loginResult.user,
|
||||||
fill: '#181825',
|
};
|
||||||
styles: {
|
|
||||||
description: 'text-center!',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
currentUser.set(loginResult.user);
|
currentUser.set(loginResult.user);
|
||||||
} else {
|
} else {
|
||||||
sileo.error({
|
userLoginResult = {
|
||||||
title: 'Login failed!',
|
message: 'Please check your username and password.',
|
||||||
description: 'Please check your username and password.',
|
};
|
||||||
fill: '#181825',
|
|
||||||
styles: {
|
|
||||||
description: 'text-center!',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
sileo.error({
|
userLoginResult = {
|
||||||
title: 'Login failed!',
|
message: 'There was an issue connecting to the server. Please try again later.',
|
||||||
description: 'There was an issue connecting to the server. Please try again later.',
|
};
|
||||||
fill: '#181825',
|
|
||||||
styles: {
|
|
||||||
description: 'text-center!',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($currentUser) {
|
if ($currentUser) {
|
||||||
@@ -194,7 +187,31 @@
|
|||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if ($firstStartup) currentView.set(SetupWizard);
|
if ($firstStartup) currentView.set(SetupWizard);
|
||||||
else currentView.set(Launch);
|
else {
|
||||||
|
currentView.set(Launch);
|
||||||
|
if (shouldLogin) {
|
||||||
|
if (userLoginResult.user) {
|
||||||
|
sileo.success({
|
||||||
|
title: 'Login successful!',
|
||||||
|
description: userLoginResult.message,
|
||||||
|
fill: '#181825',
|
||||||
|
styles: {
|
||||||
|
description: 'text-center!',
|
||||||
|
},
|
||||||
|
duration: 2500,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
sileo.error({
|
||||||
|
title: 'Login failed!',
|
||||||
|
description: userLoginResult.message,
|
||||||
|
fill: '#181825',
|
||||||
|
styles: {
|
||||||
|
description: 'text-center!',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}, 250);
|
}, 250);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user