@lobb-js/lobb-ext-auth 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/auth.d.ts +2 -1
- package/dist/auth.js +23 -4
- package/dist/index.js +41 -2
- package/dist/lib/components/pages/settings/index.svelte +1 -1
- package/dist/lib/components/pages/settings/pages/activityFeed.svelte +1 -1
- package/dist/lib/components/pages/settings/pages/rolesAndPermissions.svelte +1 -1
- package/dist/lib/components/pages/settings/pages/users.svelte +1 -1
- package/dist/lib/components/pages/userSettings/index.svelte +45 -32
- package/dist/onStartup.js +17 -2
- package/extensions/auth/collections/collections.ts +2 -0
- package/extensions/auth/collections/shares.ts +60 -0
- package/extensions/auth/config/extensionConfigSchema.d.ts +41 -0
- package/extensions/auth/config/permissionsAction/create.d.ts +18 -0
- package/extensions/auth/config/permissionsAction/delete.d.ts +3 -0
- package/extensions/auth/config/permissionsAction/read.d.ts +11 -0
- package/extensions/auth/config/permissionsAction/update.d.ts +18 -0
- package/extensions/auth/index.ts +0 -2
- package/extensions/auth/permissions.d.ts +2 -0
- package/extensions/auth/permissions.ts +34 -0
- package/extensions/auth/studio/auth.ts +25 -5
- package/extensions/auth/studio/index.ts +44 -2
- package/extensions/auth/studio/lib/components/pages/settings/index.svelte +1 -1
- package/extensions/auth/studio/lib/components/pages/settings/pages/activityFeed.svelte +1 -1
- package/extensions/auth/studio/lib/components/pages/settings/pages/rolesAndPermissions.svelte +1 -1
- package/extensions/auth/studio/lib/components/pages/settings/pages/users.svelte +1 -1
- package/extensions/auth/studio/lib/components/pages/userSettings/index.svelte +45 -32
- package/extensions/auth/studio/onStartup.ts +14 -2
- package/extensions/auth/tests/collections/shares.test.ts +657 -0
- package/extensions/auth/tests/configs/auth.ts +17 -0
- package/extensions/auth/tests/controllers/me.test.ts +104 -0
- package/extensions/auth/tests/permissions.test.ts +127 -0
- package/extensions/auth/tests/workflows/shareIntersection.test.ts +158 -0
- package/extensions/auth/workflows/baseWorkflow.ts +48 -26
- package/extensions/auth/workflows/currentUserPermissionsWorkflow.ts +32 -0
- package/extensions/auth/workflows/index.ts +12 -0
- package/extensions/auth/workflows/meAliasWorkflows.ts +26 -0
- package/extensions/auth/workflows/policiesWorkflows.ts +64 -117
- package/extensions/auth/workflows/shareIntersection.ts +64 -0
- package/extensions/auth/workflows/sharesWorkflows.ts +135 -0
- package/extensions/auth/workflows/utils.ts +132 -224
- package/package.json +3 -3
- package/dist/lib/components/pages/userSettings/components/account.svelte +0 -106
- package/dist/lib/components/pages/userSettings/components/account.svelte.d.ts +0 -14
- package/dist/lib/components/pages/userSettings/components/profile.svelte +0 -87
- package/dist/lib/components/pages/userSettings/components/profile.svelte.d.ts +0 -14
- package/extensions/auth/studio/lib/components/pages/userSettings/components/account.svelte +0 -106
- package/extensions/auth/studio/lib/components/pages/userSettings/components/profile.svelte +0 -87
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { ExtensionProps } from "@lobb-js/studio";
|
|
3
|
-
import { onMount } from "svelte";
|
|
4
|
-
|
|
5
|
-
const { utils }: ExtensionProps = $props();
|
|
6
|
-
|
|
7
|
-
let user = $state({
|
|
8
|
-
old_password: "",
|
|
9
|
-
new_password: "",
|
|
10
|
-
});
|
|
11
|
-
const icons = utils.components.Icons;
|
|
12
|
-
|
|
13
|
-
// @ts-ignore: Im sure the session object exist
|
|
14
|
-
const currentUserId = utils.ctx.extensions.auth.session.user.id;
|
|
15
|
-
let loaded = $state(false);
|
|
16
|
-
onMount(async () => {
|
|
17
|
-
const response = await utils.lobb.findOne("auth_users", currentUserId);
|
|
18
|
-
const result = await response.json();
|
|
19
|
-
user = result.data;
|
|
20
|
-
loaded = true;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
async function onUpdateCLick() {
|
|
24
|
-
if (!user.new_password) {
|
|
25
|
-
utils.toast.error("Make sure you fill the new password");
|
|
26
|
-
return;
|
|
27
|
-
} else if (!user.old_password) {
|
|
28
|
-
utils.toast.error("Make sure you fill the old password");
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const result = await utils.lobb.request({
|
|
33
|
-
method: "POST",
|
|
34
|
-
route: "/api/extensions/auth/change_password",
|
|
35
|
-
payload: {
|
|
36
|
-
old_password: user.old_password,
|
|
37
|
-
new_password: user.new_password,
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
if (result.status >= 400) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
utils.toast.success("Account updated successfully.");
|
|
46
|
-
}
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
{#if loaded}
|
|
50
|
-
<div class="flex max-w-[40rem] flex-1 flex-col gap-4 overflow-y-visible">
|
|
51
|
-
<div>
|
|
52
|
-
<div class="text-lg font-semibold">Account</div>
|
|
53
|
-
<div class="text-sm text-muted-foreground">
|
|
54
|
-
Update your account settings.
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
<utils.components.Separator />
|
|
58
|
-
<!-- TODO: add prefered language here too -->
|
|
59
|
-
<div class="flex flex-col gap-2">
|
|
60
|
-
<div class="text-sm">Change Password</div>
|
|
61
|
-
<div class="flex gap-4">
|
|
62
|
-
<utils.components.Input
|
|
63
|
-
bind:value={user.old_password}
|
|
64
|
-
placeholder="Old password"
|
|
65
|
-
type="password"
|
|
66
|
-
/>
|
|
67
|
-
<utils.components.Input
|
|
68
|
-
bind:value={user.new_password}
|
|
69
|
-
placeholder="New password"
|
|
70
|
-
type="password"
|
|
71
|
-
/>
|
|
72
|
-
</div>
|
|
73
|
-
<div class="text-xs text-muted-foreground">
|
|
74
|
-
This is where you can change your password.
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
77
|
-
<utils.components.Button
|
|
78
|
-
class="self-start"
|
|
79
|
-
onclick={onUpdateCLick}
|
|
80
|
-
Icon={icons.Pencil}
|
|
81
|
-
>
|
|
82
|
-
Update Account
|
|
83
|
-
</utils.components.Button>
|
|
84
|
-
</div>
|
|
85
|
-
{:else}
|
|
86
|
-
<div class="flex max-w-[40rem] flex-1 flex-col gap-8 overflow-y-visible">
|
|
87
|
-
<div class="grid gap-2">
|
|
88
|
-
<utils.components.Skeleton class="h-8 w-full max-w-60" />
|
|
89
|
-
<utils.components.Skeleton class="h-4 w-full max-w-96" />
|
|
90
|
-
</div>
|
|
91
|
-
<utils.components.Separator />
|
|
92
|
-
<div class="flex flex-col gap-2">
|
|
93
|
-
<utils.components.Skeleton class="h-4 w-full max-w-36" />
|
|
94
|
-
<utils.components.Skeleton class="h-8 w-full max-w-60" />
|
|
95
|
-
<utils.components.Skeleton class="h-4 w-full max-w-96" />
|
|
96
|
-
</div>
|
|
97
|
-
<div class="flex flex-col gap-2">
|
|
98
|
-
<utils.components.Skeleton class="h-4 w-full max-w-36" />
|
|
99
|
-
<div class="flex gap-4">
|
|
100
|
-
<utils.components.Skeleton class="h-8 w-full max-w-60" />
|
|
101
|
-
<utils.components.Skeleton class="h-8 w-full max-w-60" />
|
|
102
|
-
</div>
|
|
103
|
-
<utils.components.Skeleton class="h-4 w-full max-w-96" />
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
{/if}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { ExtensionProps } from "@lobb-js/studio";
|
|
3
|
-
import { onMount } from "svelte";
|
|
4
|
-
|
|
5
|
-
const { utils }: ExtensionProps = $props();
|
|
6
|
-
|
|
7
|
-
let user = $state({
|
|
8
|
-
name: "",
|
|
9
|
-
});
|
|
10
|
-
const icons = utils.components.Icons;
|
|
11
|
-
|
|
12
|
-
// @ts-ignore: Im sure the session object exist
|
|
13
|
-
const currentUserId = utils.ctx.extensions.auth.session.user.id;
|
|
14
|
-
let loaded = $state(false);
|
|
15
|
-
onMount(async () => {
|
|
16
|
-
const response = await utils.lobb.findOne("auth_users", currentUserId);
|
|
17
|
-
const result = await response.json();
|
|
18
|
-
user = result.data;
|
|
19
|
-
loaded = true;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
async function onUpdateCLick() {
|
|
23
|
-
// TODO: add the logic of updating some of the current user's information
|
|
24
|
-
const updateObject: any = {};
|
|
25
|
-
updateObject["name"] = user.name;
|
|
26
|
-
const response = await utils.lobb.updateOne(
|
|
27
|
-
"auth_users",
|
|
28
|
-
currentUserId,
|
|
29
|
-
updateObject,
|
|
30
|
-
);
|
|
31
|
-
if (response.status >= 400) {
|
|
32
|
-
const result = await response.json();
|
|
33
|
-
utils.toast.error(result.message);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
utils.toast.success("Profile updated successfully.");
|
|
37
|
-
}
|
|
38
|
-
</script>
|
|
39
|
-
|
|
40
|
-
{#if loaded}
|
|
41
|
-
<div class="flex max-w-[40rem] flex-1 flex-col gap-4 overflow-y-visible">
|
|
42
|
-
<div>
|
|
43
|
-
<div class="text-lg font-semibold">Profile</div>
|
|
44
|
-
<div class="text-sm text-muted-foreground">
|
|
45
|
-
Edit information that others will see.
|
|
46
|
-
</div>
|
|
47
|
-
</div>
|
|
48
|
-
<utils.components.Separator />
|
|
49
|
-
<!-- TODO: you should add name and other stuff like phone number and stuff like that -->
|
|
50
|
-
<div class="flex flex-col gap-2">
|
|
51
|
-
<div class="text-sm">Full Name</div>
|
|
52
|
-
<utils.components.Input
|
|
53
|
-
placeholder="Full Name"
|
|
54
|
-
bind:value={user.name}
|
|
55
|
-
/>
|
|
56
|
-
<div class="text-xs text-muted-foreground">
|
|
57
|
-
This is your public display name. It can be your real name or a
|
|
58
|
-
pseudonym.
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
<utils.components.Button
|
|
62
|
-
class="self-start"
|
|
63
|
-
onclick={onUpdateCLick}
|
|
64
|
-
Icon={icons.Pencil}
|
|
65
|
-
>
|
|
66
|
-
Update Profile
|
|
67
|
-
</utils.components.Button>
|
|
68
|
-
</div>
|
|
69
|
-
{:else}
|
|
70
|
-
<div class="flex max-w-[40rem] flex-1 flex-col gap-8 overflow-y-visible">
|
|
71
|
-
<div class="grid gap-2">
|
|
72
|
-
<utils.components.Skeleton class="h-8 w-full max-w-60" />
|
|
73
|
-
<utils.components.Skeleton class="h-4 w-full max-w-96" />
|
|
74
|
-
</div>
|
|
75
|
-
<utils.components.Separator />
|
|
76
|
-
<div class="flex flex-col gap-2">
|
|
77
|
-
<utils.components.Skeleton class="h-4 w-full max-w-36" />
|
|
78
|
-
<utils.components.Skeleton class="h-8 w-full max-w-60" />
|
|
79
|
-
<utils.components.Skeleton class="h-4 w-full max-w-96" />
|
|
80
|
-
</div>
|
|
81
|
-
<div class="flex flex-col gap-2">
|
|
82
|
-
<utils.components.Skeleton class="h-4 w-full max-w-36" />
|
|
83
|
-
<utils.components.Skeleton class="h-8 w-full max-w-60" />
|
|
84
|
-
<utils.components.Skeleton class="h-4 w-full max-w-96" />
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
{/if}
|