mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 10:53:31 +00:00
If user has no linked account, ensure that their skin is set to default
This commit is contained in:
@@ -131,3 +131,14 @@ export function getAudience() {
|
||||
const domainname = hostname.split(".").slice(-2).join(".");
|
||||
return domainname;
|
||||
}
|
||||
|
||||
// Check if the user's account is linked to a Discord or email account.
|
||||
export function hasLinkedAccount(
|
||||
userMeResponse: UserMeResponse | false,
|
||||
): boolean {
|
||||
return (
|
||||
userMeResponse !== false &&
|
||||
(userMeResponse.user?.discord !== undefined ||
|
||||
userMeResponse.user?.email !== undefined)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { UserMeResponse } from "../core/ApiSchemas";
|
||||
import { ColorPalette, Cosmetics, Pattern } from "../core/CosmeticSchemas";
|
||||
import { UserSettings } from "../core/game/UserSettings";
|
||||
import { PlayerPattern } from "../core/Schemas";
|
||||
import { hasLinkedAccount } from "./Api";
|
||||
import "./components/Difficulties";
|
||||
import "./components/PatternButton";
|
||||
import { renderPatternPreview } from "./components/PatternButton";
|
||||
@@ -55,7 +56,7 @@ export class TerritoryPatternsModal extends LitElement {
|
||||
}
|
||||
|
||||
async onUserMe(userMeResponse: UserMeResponse | false) {
|
||||
if (userMeResponse === false) {
|
||||
if (!hasLinkedAccount(userMeResponse)) {
|
||||
this.userSettings.setSelectedPatternName(undefined);
|
||||
this.selectedPattern = null;
|
||||
this.selectedColor = null;
|
||||
@@ -134,7 +135,7 @@ export class TerritoryPatternsModal extends LitElement {
|
||||
return html`
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="flex justify-center">
|
||||
${this.isLoggedIn()
|
||||
${hasLinkedAccount(this.userMeResponse)
|
||||
? this.renderMySkinsButton()
|
||||
: this.renderNotLoggedInWarning()}
|
||||
</div>
|
||||
@@ -290,14 +291,4 @@ export class TerritoryPatternsModal extends LitElement {
|
||||
render(preview, this.previewButton);
|
||||
this.requestUpdate();
|
||||
}
|
||||
|
||||
private isLoggedIn(): boolean {
|
||||
if (this.userMeResponse === false) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
this.userMeResponse.user.discord !== undefined ||
|
||||
this.userMeResponse.user.email !== undefined
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user