@adminforth/email-invite 1.0.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/.woodpecker/buildRelease.sh +13 -0
- package/.woodpecker/buildSlackNotify.sh +44 -0
- package/.woodpecker/release.yml +41 -0
- package/build.log +11 -0
- package/custom/SetPassword.vue +262 -0
- package/custom/tsconfig.json +19 -0
- package/dist/custom/SetPassword.vue +262 -0
- package/dist/custom/tsconfig.json +19 -0
- package/dist/index.js +269 -0
- package/dist/types.js +1 -0
- package/index.ts +331 -0
- package/package.json +56 -0
- package/tsconfig.json +13 -0
- package/types.ts +31 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
#!/bin/bash
|
|
3
|
+
|
|
4
|
+
# write npm run output both to console and to build.log
|
|
5
|
+
npm run build 2>&1 | tee build.log
|
|
6
|
+
build_status=${PIPESTATUS[0]}
|
|
7
|
+
|
|
8
|
+
# if exist status from the npm run build is not 0
|
|
9
|
+
# then exit with the status code from the npm run build
|
|
10
|
+
if [ $build_status -ne 0 ]; then
|
|
11
|
+
echo "Build failed. Exiting with status code $build_status"
|
|
12
|
+
exit $build_status
|
|
13
|
+
fi
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -x
|
|
4
|
+
|
|
5
|
+
COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
if [ "$CI_PREV_PIPELINE_STATUS" = "success" ]; then
|
|
9
|
+
MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
10
|
+
|
|
11
|
+
curl -s -X POST -H "Content-Type: application/json" -d '{
|
|
12
|
+
"username": "'"$CI_COMMIT_AUTHOR"'",
|
|
13
|
+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
|
|
14
|
+
"attachments": [
|
|
15
|
+
{
|
|
16
|
+
"mrkdwn_in": ["text", "pretext"],
|
|
17
|
+
"color": "#36a64f",
|
|
18
|
+
"text": "'"$MESSAGE"'"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}' "$DEVELOPERS_SLACK_WEBHOOK"
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
export BUILD_LOG=$(cat ./build.log)
|
|
25
|
+
|
|
26
|
+
BUILD_LOG=$(echo $BUILD_LOG | sed 's/"/\\"/g')
|
|
27
|
+
|
|
28
|
+
MESSAGE="Broke \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\` with commit _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
29
|
+
CODE_BLOCK="\`\`\`$BUILD_LOG\n\`\`\`"
|
|
30
|
+
|
|
31
|
+
echo "Sending slack message to developers $MESSAGE"
|
|
32
|
+
# Send the message
|
|
33
|
+
curl -sS -X POST -H "Content-Type: application/json" -d '{
|
|
34
|
+
"username": "'"$CI_COMMIT_AUTHOR"'",
|
|
35
|
+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
|
|
36
|
+
"attachments": [
|
|
37
|
+
{
|
|
38
|
+
"mrkdwn_in": ["text", "pretext"],
|
|
39
|
+
"color": "#8A1C12",
|
|
40
|
+
"text": "'"$CODE_BLOCK"'",
|
|
41
|
+
"pretext": "'"$MESSAGE"'"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}' "$DEVELOPERS_SLACK_WEBHOOK" 2>&1
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
clone:
|
|
2
|
+
git:
|
|
3
|
+
image: woodpeckerci/plugin-git
|
|
4
|
+
settings:
|
|
5
|
+
partial: false
|
|
6
|
+
depth: 5
|
|
7
|
+
|
|
8
|
+
steps:
|
|
9
|
+
init-secrets:
|
|
10
|
+
when:
|
|
11
|
+
- event: push
|
|
12
|
+
image: infisical/cli
|
|
13
|
+
environment:
|
|
14
|
+
INFISICAL_TOKEN:
|
|
15
|
+
from_secret: VAULT_TOKEN
|
|
16
|
+
commands:
|
|
17
|
+
- infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
|
|
18
|
+
|
|
19
|
+
release:
|
|
20
|
+
image: node:20
|
|
21
|
+
when:
|
|
22
|
+
- event: push
|
|
23
|
+
volumes:
|
|
24
|
+
- /var/run/docker.sock:/var/run/docker.sock
|
|
25
|
+
commands:
|
|
26
|
+
- apt update && apt install -y rsync
|
|
27
|
+
- export $(cat /woodpecker/deploy.vault.env | xargs)
|
|
28
|
+
- npm clean-install
|
|
29
|
+
- /bin/bash ./.woodpecker/buildRelease.sh
|
|
30
|
+
- npm audit signatures
|
|
31
|
+
- npx semantic-release
|
|
32
|
+
|
|
33
|
+
slack-on-failure:
|
|
34
|
+
when:
|
|
35
|
+
- event: push
|
|
36
|
+
status: [failure, success]
|
|
37
|
+
image: curlimages/curl
|
|
38
|
+
commands:
|
|
39
|
+
- export $(cat /woodpecker/deploy.vault.env | xargs)
|
|
40
|
+
- /bin/sh ./.woodpecker/buildSlackNotify.sh
|
|
41
|
+
|
package/build.log
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
> @adminforth/email-invite@1.0.0 build
|
|
3
|
+
> tsc && rsync -av --exclude 'node_modules' custom dist/
|
|
4
|
+
|
|
5
|
+
sending incremental file list
|
|
6
|
+
custom/
|
|
7
|
+
custom/SetPassword.vue
|
|
8
|
+
custom/tsconfig.json
|
|
9
|
+
|
|
10
|
+
sent 13,814 bytes received 58 bytes 27,744.00 bytes/sec
|
|
11
|
+
total size is 13,599 speedup is 0.98
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="relative flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-800 relative w-screen h-screen"
|
|
3
|
+
:style="coreStore.config?.loginBackgroundImage && backgroundPosition === 'over' ? {
|
|
4
|
+
'background-image': 'url(' + loadFile(coreStore.config?.loginBackgroundImage) + ')',
|
|
5
|
+
'background-size': 'cover',
|
|
6
|
+
'background-position': 'center',
|
|
7
|
+
'background-blend-mode': 'darken'
|
|
8
|
+
}: {}"
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
<img v-if="coreStore.config?.loginBackgroundImage && backgroundPosition !== 'over'"
|
|
12
|
+
:src="loadFile(coreStore.config?.loginBackgroundImage)"
|
|
13
|
+
class="position-absolute top-0 left-0 h-screen object-cover w-0"
|
|
14
|
+
:class="{
|
|
15
|
+
'1/2': 'md:w-1/2',
|
|
16
|
+
'1/3': 'md:w-1/3',
|
|
17
|
+
'2/3': 'md:w-2/3',
|
|
18
|
+
'3/4': 'md:w-3/4',
|
|
19
|
+
'2/5': 'md:w-2/5',
|
|
20
|
+
'3/5': 'md:w-3/5',
|
|
21
|
+
}[backgroundPosition]"
|
|
22
|
+
/>
|
|
23
|
+
|
|
24
|
+
<!-- Main modal -->
|
|
25
|
+
<div id="authentication-modal" tabindex="-1"
|
|
26
|
+
class="overflow-y-auto flex flex-grow
|
|
27
|
+
overflow-x-hidden z-50 min-w-[350px] justify-center items-center md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
|
28
|
+
<div class="relative p-4 w-full max-h-full max-w-[400px]">
|
|
29
|
+
<!-- Modal content -->
|
|
30
|
+
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black" >
|
|
31
|
+
<!-- Modal header -->
|
|
32
|
+
<div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t dark:border-gray-600">
|
|
33
|
+
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
|
|
34
|
+
{{$t('Set your password for')}} {{ coreStore.config?.brandName }}
|
|
35
|
+
</h3>
|
|
36
|
+
</div>
|
|
37
|
+
<!-- Modal body -->
|
|
38
|
+
<div class="p-4 md:p-5">
|
|
39
|
+
<!-- Success message -->
|
|
40
|
+
<div v-if="passwordSet" class="flex items-center justify-center p-4 mb-4 text-sm text-green-800 rounded-lg bg-green-50 dark:bg-green-800 dark:text-green-400" role="alert">
|
|
41
|
+
<div class="text-center">
|
|
42
|
+
<p class="mb-3">{{$t('Password set successfully!')}}</p>
|
|
43
|
+
<Link to="/login" class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
44
|
+
{{$t('Go to Login')}}
|
|
45
|
+
</Link>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<!-- Set password form -->
|
|
50
|
+
<form v-if="!passwordSet && tokenValid" class="space-y-4" role="alert" @submit.prevent>
|
|
51
|
+
<div class="relative">
|
|
52
|
+
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Password')}}</label>
|
|
53
|
+
<input
|
|
54
|
+
:type="unmasked ? 'text' : 'password'"
|
|
55
|
+
name="password" id="password"
|
|
56
|
+
autocomplete="new-password"
|
|
57
|
+
v-model="password"
|
|
58
|
+
@keydown.enter="passwordConfirmationInput?.focus()"
|
|
59
|
+
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white"
|
|
60
|
+
:placeholder="$t('Enter your password')" required
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
@click="unmasked = !unmasked"
|
|
66
|
+
class="h-6 absolute inset-y-2 top-9 right-1 flex items-center pr-2 z-index-100 focus:outline-none"
|
|
67
|
+
>
|
|
68
|
+
<IconEyeSolid class="w-6 h-6 text-gray-400" v-if="!unmasked" />
|
|
69
|
+
<IconEyeSlashSolid class="w-6 h-6 text-gray-400" v-else />
|
|
70
|
+
</button>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<div class="relative">
|
|
74
|
+
<label for="password_confirmation" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Confirm password')}}</label>
|
|
75
|
+
<input
|
|
76
|
+
:type="unmasked ? 'text' : 'password'"
|
|
77
|
+
name="password_confirmation" id="password_confirmation"
|
|
78
|
+
autocomplete="new-password"
|
|
79
|
+
v-model="passwordConfirmation"
|
|
80
|
+
ref="passwordConfirmationInput"
|
|
81
|
+
@keydown.enter="setPassword"
|
|
82
|
+
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white"
|
|
83
|
+
:placeholder="$t('Confirm your password')" required
|
|
84
|
+
/>
|
|
85
|
+
|
|
86
|
+
<button
|
|
87
|
+
type="button"
|
|
88
|
+
@click="unmasked = !unmasked"
|
|
89
|
+
class="h-6 absolute inset-y-2 top-9 right-1 flex items-center pr-2 z-index-100 focus:outline-none"
|
|
90
|
+
>
|
|
91
|
+
<IconEyeSolid class="w-6 h-6 text-gray-400" v-if="!unmasked" />
|
|
92
|
+
<IconEyeSlashSolid class="w-6 h-6 text-gray-400" v-else />
|
|
93
|
+
</button>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<div v-if="validationError || error" class="flex items-center p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400" role="alert">
|
|
97
|
+
<svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
98
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
|
|
99
|
+
</svg>
|
|
100
|
+
<span class="sr-only">{{$t('Info')}}</span>
|
|
101
|
+
<div>
|
|
102
|
+
{{ validationError || error }}
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<Button
|
|
107
|
+
:disabled="inProgress || (validationRunning && validationError)"
|
|
108
|
+
@click="setPassword"
|
|
109
|
+
class="w-full">
|
|
110
|
+
<svg v-if="inProgress"
|
|
111
|
+
aria-hidden="true" class="w-4 h-4 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
112
|
+
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
|
|
113
|
+
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
|
|
114
|
+
</svg>
|
|
115
|
+
{{$t('Set Password')}}
|
|
116
|
+
</Button>
|
|
117
|
+
</form>
|
|
118
|
+
|
|
119
|
+
<!-- Invalid token message -->
|
|
120
|
+
<div v-if="!tokenValid && !loading" class="flex items-center p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400" role="alert">
|
|
121
|
+
<svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
122
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
|
|
123
|
+
</svg>
|
|
124
|
+
<span class="sr-only">{{$t('Info')}}</span>
|
|
125
|
+
<div>
|
|
126
|
+
<p class="mb-2">{{$t('This invitation link is invalid or has expired.')}}</p>
|
|
127
|
+
<Link to="/login">{{$t('Go to Login')}}</Link>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<!-- Loading state -->
|
|
132
|
+
<div v-if="loading" class="flex items-center justify-center p-8">
|
|
133
|
+
<svg aria-hidden="true" class="w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
134
|
+
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
|
|
135
|
+
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
|
|
136
|
+
</svg>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
</div>
|
|
144
|
+
</template>
|
|
145
|
+
|
|
146
|
+
<script setup lang="ts">
|
|
147
|
+
import { onMounted, ref, computed, Ref } from 'vue';
|
|
148
|
+
import { useCoreStore } from '@/stores/core';
|
|
149
|
+
import { callAdminForthApi, loadFile, applyRegexValidation } from '@/utils';
|
|
150
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
151
|
+
import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
|
|
152
|
+
import Button from '@/afcl/Button.vue';
|
|
153
|
+
import Link from '@/afcl/Link.vue';
|
|
154
|
+
|
|
155
|
+
const inProgress = ref(false);
|
|
156
|
+
const loading = ref(true);
|
|
157
|
+
const tokenValid = ref(false);
|
|
158
|
+
const passwordSet = ref(false);
|
|
159
|
+
|
|
160
|
+
const coreStore = useCoreStore();
|
|
161
|
+
|
|
162
|
+
const passwordConfirmationInput = ref(null);
|
|
163
|
+
const password = ref("");
|
|
164
|
+
const passwordConfirmation = ref("");
|
|
165
|
+
const unmasked = ref(false);
|
|
166
|
+
|
|
167
|
+
const route = useRoute();
|
|
168
|
+
const router = useRouter();
|
|
169
|
+
|
|
170
|
+
const validationRunning = ref(false);
|
|
171
|
+
const error = ref(null);
|
|
172
|
+
|
|
173
|
+
const backgroundPosition = computed(() => {
|
|
174
|
+
return coreStore.config?.loginBackgroundPosition || '1/2';
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const passwordField = computed(
|
|
178
|
+
() => route.meta.passwordField
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
function checkPassword() {
|
|
183
|
+
|
|
184
|
+
if (!password.value || !passwordConfirmation.value) {
|
|
185
|
+
return 'Please enter both password and password confirmation';
|
|
186
|
+
}
|
|
187
|
+
if (password.value !== passwordConfirmation.value) {
|
|
188
|
+
return 'Passwords do not match';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (password.value.length < passwordField.value.minLength) {
|
|
192
|
+
return `Password must be at least ${passwordField.value.minLength} characters long`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (password.value.length > passwordField.value.maxLength) {
|
|
196
|
+
return `Password must be at most ${passwordField.value.maxLength} characters long`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (passwordField.value.validation) {
|
|
200
|
+
const valError = applyRegexValidation(password.value, passwordField.value.validation);
|
|
201
|
+
if (valError) {
|
|
202
|
+
return valError;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const validationError = computed(() => {
|
|
210
|
+
if (validationRunning.value) {
|
|
211
|
+
return checkPassword();
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
onMounted(async () => {
|
|
217
|
+
loading.value = true;
|
|
218
|
+
await coreStore.getPublicConfig();
|
|
219
|
+
|
|
220
|
+
// Check if token is present and valid
|
|
221
|
+
const token = route.query.token;
|
|
222
|
+
if (token) {
|
|
223
|
+
tokenValid.value = true;
|
|
224
|
+
} else {
|
|
225
|
+
tokenValid.value = false;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
loading.value = false;
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
async function setPassword() {
|
|
232
|
+
error.value = null;
|
|
233
|
+
|
|
234
|
+
if (checkPassword()) {
|
|
235
|
+
validationRunning.value = true;
|
|
236
|
+
return;
|
|
237
|
+
} else {
|
|
238
|
+
validationRunning.value = false;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
inProgress.value = true;
|
|
242
|
+
const resp = await callAdminForthApi({
|
|
243
|
+
path: `/plugin/${route.meta.pluginInstanceId}/set-password`,
|
|
244
|
+
method: 'POST',
|
|
245
|
+
body: {
|
|
246
|
+
token: route.query.token,
|
|
247
|
+
password: password.value,
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
inProgress.value = false;
|
|
251
|
+
|
|
252
|
+
if (resp.error) {
|
|
253
|
+
error.value = resp.error;
|
|
254
|
+
if (resp.error.includes('Invalid') || resp.error.includes('expired')) {
|
|
255
|
+
tokenValid.value = false;
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
error.value = null;
|
|
259
|
+
passwordSet.value = true;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".", // This should point to your project root
|
|
4
|
+
"paths": {
|
|
5
|
+
"@/*": [
|
|
6
|
+
// "node_modules/adminforth/dist/spa/src/*"
|
|
7
|
+
"../../../spa/src/*"
|
|
8
|
+
],
|
|
9
|
+
"*": [
|
|
10
|
+
// "node_modules/adminforth/dist/spa/node_modules/*"
|
|
11
|
+
"../../../spa/node_modules/*"
|
|
12
|
+
],
|
|
13
|
+
"@@/*": [
|
|
14
|
+
// "node_modules/adminforth/dist/spa/src/*"
|
|
15
|
+
"."
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="relative flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-800 relative w-screen h-screen"
|
|
3
|
+
:style="coreStore.config?.loginBackgroundImage && backgroundPosition === 'over' ? {
|
|
4
|
+
'background-image': 'url(' + loadFile(coreStore.config?.loginBackgroundImage) + ')',
|
|
5
|
+
'background-size': 'cover',
|
|
6
|
+
'background-position': 'center',
|
|
7
|
+
'background-blend-mode': 'darken'
|
|
8
|
+
}: {}"
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
<img v-if="coreStore.config?.loginBackgroundImage && backgroundPosition !== 'over'"
|
|
12
|
+
:src="loadFile(coreStore.config?.loginBackgroundImage)"
|
|
13
|
+
class="position-absolute top-0 left-0 h-screen object-cover w-0"
|
|
14
|
+
:class="{
|
|
15
|
+
'1/2': 'md:w-1/2',
|
|
16
|
+
'1/3': 'md:w-1/3',
|
|
17
|
+
'2/3': 'md:w-2/3',
|
|
18
|
+
'3/4': 'md:w-3/4',
|
|
19
|
+
'2/5': 'md:w-2/5',
|
|
20
|
+
'3/5': 'md:w-3/5',
|
|
21
|
+
}[backgroundPosition]"
|
|
22
|
+
/>
|
|
23
|
+
|
|
24
|
+
<!-- Main modal -->
|
|
25
|
+
<div id="authentication-modal" tabindex="-1"
|
|
26
|
+
class="overflow-y-auto flex flex-grow
|
|
27
|
+
overflow-x-hidden z-50 min-w-[350px] justify-center items-center md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
|
28
|
+
<div class="relative p-4 w-full max-h-full max-w-[400px]">
|
|
29
|
+
<!-- Modal content -->
|
|
30
|
+
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black" >
|
|
31
|
+
<!-- Modal header -->
|
|
32
|
+
<div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t dark:border-gray-600">
|
|
33
|
+
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
|
|
34
|
+
{{$t('Set your password for')}} {{ coreStore.config?.brandName }}
|
|
35
|
+
</h3>
|
|
36
|
+
</div>
|
|
37
|
+
<!-- Modal body -->
|
|
38
|
+
<div class="p-4 md:p-5">
|
|
39
|
+
<!-- Success message -->
|
|
40
|
+
<div v-if="passwordSet" class="flex items-center justify-center p-4 mb-4 text-sm text-green-800 rounded-lg bg-green-50 dark:bg-green-800 dark:text-green-400" role="alert">
|
|
41
|
+
<div class="text-center">
|
|
42
|
+
<p class="mb-3">{{$t('Password set successfully!')}}</p>
|
|
43
|
+
<Link to="/login" class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
44
|
+
{{$t('Go to Login')}}
|
|
45
|
+
</Link>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<!-- Set password form -->
|
|
50
|
+
<form v-if="!passwordSet && tokenValid" class="space-y-4" role="alert" @submit.prevent>
|
|
51
|
+
<div class="relative">
|
|
52
|
+
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Password')}}</label>
|
|
53
|
+
<input
|
|
54
|
+
:type="unmasked ? 'text' : 'password'"
|
|
55
|
+
name="password" id="password"
|
|
56
|
+
autocomplete="new-password"
|
|
57
|
+
v-model="password"
|
|
58
|
+
@keydown.enter="passwordConfirmationInput?.focus()"
|
|
59
|
+
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white"
|
|
60
|
+
:placeholder="$t('Enter your password')" required
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
@click="unmasked = !unmasked"
|
|
66
|
+
class="h-6 absolute inset-y-2 top-9 right-1 flex items-center pr-2 z-index-100 focus:outline-none"
|
|
67
|
+
>
|
|
68
|
+
<IconEyeSolid class="w-6 h-6 text-gray-400" v-if="!unmasked" />
|
|
69
|
+
<IconEyeSlashSolid class="w-6 h-6 text-gray-400" v-else />
|
|
70
|
+
</button>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<div class="relative">
|
|
74
|
+
<label for="password_confirmation" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Confirm password')}}</label>
|
|
75
|
+
<input
|
|
76
|
+
:type="unmasked ? 'text' : 'password'"
|
|
77
|
+
name="password_confirmation" id="password_confirmation"
|
|
78
|
+
autocomplete="new-password"
|
|
79
|
+
v-model="passwordConfirmation"
|
|
80
|
+
ref="passwordConfirmationInput"
|
|
81
|
+
@keydown.enter="setPassword"
|
|
82
|
+
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white"
|
|
83
|
+
:placeholder="$t('Confirm your password')" required
|
|
84
|
+
/>
|
|
85
|
+
|
|
86
|
+
<button
|
|
87
|
+
type="button"
|
|
88
|
+
@click="unmasked = !unmasked"
|
|
89
|
+
class="h-6 absolute inset-y-2 top-9 right-1 flex items-center pr-2 z-index-100 focus:outline-none"
|
|
90
|
+
>
|
|
91
|
+
<IconEyeSolid class="w-6 h-6 text-gray-400" v-if="!unmasked" />
|
|
92
|
+
<IconEyeSlashSolid class="w-6 h-6 text-gray-400" v-else />
|
|
93
|
+
</button>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<div v-if="validationError || error" class="flex items-center p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400" role="alert">
|
|
97
|
+
<svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
98
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
|
|
99
|
+
</svg>
|
|
100
|
+
<span class="sr-only">{{$t('Info')}}</span>
|
|
101
|
+
<div>
|
|
102
|
+
{{ validationError || error }}
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<Button
|
|
107
|
+
:disabled="inProgress || (validationRunning && validationError)"
|
|
108
|
+
@click="setPassword"
|
|
109
|
+
class="w-full">
|
|
110
|
+
<svg v-if="inProgress"
|
|
111
|
+
aria-hidden="true" class="w-4 h-4 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
112
|
+
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
|
|
113
|
+
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
|
|
114
|
+
</svg>
|
|
115
|
+
{{$t('Set Password')}}
|
|
116
|
+
</Button>
|
|
117
|
+
</form>
|
|
118
|
+
|
|
119
|
+
<!-- Invalid token message -->
|
|
120
|
+
<div v-if="!tokenValid && !loading" class="flex items-center p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400" role="alert">
|
|
121
|
+
<svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
122
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
|
|
123
|
+
</svg>
|
|
124
|
+
<span class="sr-only">{{$t('Info')}}</span>
|
|
125
|
+
<div>
|
|
126
|
+
<p class="mb-2">{{$t('This invitation link is invalid or has expired.')}}</p>
|
|
127
|
+
<Link to="/login">{{$t('Go to Login')}}</Link>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<!-- Loading state -->
|
|
132
|
+
<div v-if="loading" class="flex items-center justify-center p-8">
|
|
133
|
+
<svg aria-hidden="true" class="w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
134
|
+
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
|
|
135
|
+
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
|
|
136
|
+
</svg>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
</div>
|
|
144
|
+
</template>
|
|
145
|
+
|
|
146
|
+
<script setup lang="ts">
|
|
147
|
+
import { onMounted, ref, computed, Ref } from 'vue';
|
|
148
|
+
import { useCoreStore } from '@/stores/core';
|
|
149
|
+
import { callAdminForthApi, loadFile, applyRegexValidation } from '@/utils';
|
|
150
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
151
|
+
import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
|
|
152
|
+
import Button from '@/afcl/Button.vue';
|
|
153
|
+
import Link from '@/afcl/Link.vue';
|
|
154
|
+
|
|
155
|
+
const inProgress = ref(false);
|
|
156
|
+
const loading = ref(true);
|
|
157
|
+
const tokenValid = ref(false);
|
|
158
|
+
const passwordSet = ref(false);
|
|
159
|
+
|
|
160
|
+
const coreStore = useCoreStore();
|
|
161
|
+
|
|
162
|
+
const passwordConfirmationInput = ref(null);
|
|
163
|
+
const password = ref("");
|
|
164
|
+
const passwordConfirmation = ref("");
|
|
165
|
+
const unmasked = ref(false);
|
|
166
|
+
|
|
167
|
+
const route = useRoute();
|
|
168
|
+
const router = useRouter();
|
|
169
|
+
|
|
170
|
+
const validationRunning = ref(false);
|
|
171
|
+
const error = ref(null);
|
|
172
|
+
|
|
173
|
+
const backgroundPosition = computed(() => {
|
|
174
|
+
return coreStore.config?.loginBackgroundPosition || '1/2';
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const passwordField = computed(
|
|
178
|
+
() => route.meta.passwordField
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
function checkPassword() {
|
|
183
|
+
|
|
184
|
+
if (!password.value || !passwordConfirmation.value) {
|
|
185
|
+
return 'Please enter both password and password confirmation';
|
|
186
|
+
}
|
|
187
|
+
if (password.value !== passwordConfirmation.value) {
|
|
188
|
+
return 'Passwords do not match';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (password.value.length < passwordField.value.minLength) {
|
|
192
|
+
return `Password must be at least ${passwordField.value.minLength} characters long`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (password.value.length > passwordField.value.maxLength) {
|
|
196
|
+
return `Password must be at most ${passwordField.value.maxLength} characters long`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (passwordField.value.validation) {
|
|
200
|
+
const valError = applyRegexValidation(password.value, passwordField.value.validation);
|
|
201
|
+
if (valError) {
|
|
202
|
+
return valError;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const validationError = computed(() => {
|
|
210
|
+
if (validationRunning.value) {
|
|
211
|
+
return checkPassword();
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
onMounted(async () => {
|
|
217
|
+
loading.value = true;
|
|
218
|
+
await coreStore.getPublicConfig();
|
|
219
|
+
|
|
220
|
+
// Check if token is present and valid
|
|
221
|
+
const token = route.query.token;
|
|
222
|
+
if (token) {
|
|
223
|
+
tokenValid.value = true;
|
|
224
|
+
} else {
|
|
225
|
+
tokenValid.value = false;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
loading.value = false;
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
async function setPassword() {
|
|
232
|
+
error.value = null;
|
|
233
|
+
|
|
234
|
+
if (checkPassword()) {
|
|
235
|
+
validationRunning.value = true;
|
|
236
|
+
return;
|
|
237
|
+
} else {
|
|
238
|
+
validationRunning.value = false;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
inProgress.value = true;
|
|
242
|
+
const resp = await callAdminForthApi({
|
|
243
|
+
path: `/plugin/${route.meta.pluginInstanceId}/set-password`,
|
|
244
|
+
method: 'POST',
|
|
245
|
+
body: {
|
|
246
|
+
token: route.query.token,
|
|
247
|
+
password: password.value,
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
inProgress.value = false;
|
|
251
|
+
|
|
252
|
+
if (resp.error) {
|
|
253
|
+
error.value = resp.error;
|
|
254
|
+
if (resp.error.includes('Invalid') || resp.error.includes('expired')) {
|
|
255
|
+
tokenValid.value = false;
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
error.value = null;
|
|
259
|
+
passwordSet.value = true;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
</script>
|