feat(core): Refactored plugin and request handling to use idpInterfaces

This commit is contained in:
2024-10-07 10:26:21 +02:00
parent 1bfdc67a0e
commit 03a8536297
25 changed files with 267 additions and 126 deletions
+52 -15
View File
@@ -9,6 +9,7 @@ import {
cssManager,
unsafeCSS,
css,
resolveExec,
type TemplateResult,
} from '@design.estate/dees-element';
import type { IdpViewcontainer } from '../views/viewcontainer.js';
@@ -41,7 +42,7 @@ export class IdpWelcome extends DeesElement {
margin: 0px auto;
padding: 24px 24px 0px 24px;
width: 500px;
letter-spacing:0.0125em;
letter-spacing: 0.0125em;
}
.textbox {
@@ -56,24 +57,56 @@ export class IdpWelcome extends DeesElement {
.textbox dees-button {
margin-top: 16px;
}
`,
`,
];
public render(): TemplateResult {
return html`
<style></style>
<h1>idp.global</h1>
<div class="textbox">
Do you want to sign in or register?
<dees-button @click=${async () => {
${resolveExec(async () => {
const idpState = await IdpState.getSingletonInstance();
idpState.domtools.router.pushUrl('/login');
}}>Sign In</dees-button>
<dees-button @click=${async () => {
const idpState = await IdpState.getSingletonInstance();
idpState.domtools.router.pushUrl('/register');
}}>Register</dees-button>
await idpState.idpClient.determineLoginStatus();
const data = await idpState.idpClient.whoIs().catch();
if (data?.user) {
return html`
Hello ${data.user.data.name}!
<dees-button
@click=${async () => {
const idpState = await IdpState.getSingletonInstance();
idpState.domtools.router.pushUrl('/account');
}}
>Manage your account</dees-button
>
<dees-button
@click=${async () => {
const idpState = await IdpState.getSingletonInstance();
idpState.domtools.router.pushUrl('/logout');
}}
>Logout</dees-button
>
`
}
return html`
Do you want to sign in or register?
<dees-button
@click=${async () => {
const idpState = await IdpState.getSingletonInstance();
idpState.domtools.router.pushUrl('/login');
}}
>Sign In</dees-button
>
<dees-button
@click=${async () => {
const idpState = await IdpState.getSingletonInstance();
idpState.domtools.router.pushUrl('/register');
}}
>Register</dees-button
>
`;
})}
</div>
<div class="textbox">
@@ -82,10 +115,14 @@ export class IdpWelcome extends DeesElement {
</div>
<div class="textbox">
idp.global is a Open Source identity provider for the world wide web. You can get the code if you want to improve it.
<dees-button @click=${() => {
window.open('https://code.foss.global/idp.global/idp.global', '_blank');
}}>Get the code</dees-button>
idp.global is a Open Source identity provider for the world wide web. You can get the code
if you want to improve it.
<dees-button
@click=${() => {
window.open('https://code.foss.global/idp.global/idp.global', '_blank');
}}
>Get the code</dees-button
>
</div>
`;
}