@drax/identity-front 0.0.8 → 0.0.10

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.
Files changed (46) hide show
  1. package/package.json +6 -18
  2. package/src/errors/BadCredentialsError.ts +8 -0
  3. package/src/factories/providers/AuthProviderFactory.ts +29 -0
  4. package/src/{core/factories → factories}/system/AuthSystemFactory.ts +2 -2
  5. package/src/helpers/AuthHelper.ts +32 -0
  6. package/src/helpers/JwtDecodeHelper.ts +79 -0
  7. package/src/i18n/identity-permissions-i18n.ts +43 -0
  8. package/src/i18n/identity-role-i18n.ts +27 -0
  9. package/src/i18n/identity-user-i18n.ts +59 -0
  10. package/src/i18n/identity-validation-i18n.ts +29 -0
  11. package/src/i18n/index.ts +10 -0
  12. package/src/index.ts +52 -10
  13. package/src/interfaces/IAuthProvider.ts +12 -0
  14. package/src/interfaces/IAuthUser.ts +15 -0
  15. package/src/interfaces/ILoginResponse.ts +5 -0
  16. package/src/interfaces/IRole.ts +10 -0
  17. package/src/interfaces/IRoleProvider.ts +13 -0
  18. package/src/interfaces/IUser.ts +39 -0
  19. package/src/interfaces/IUserProvider.ts +14 -0
  20. package/src/providers/gql/AuthGqlProvider.ts +59 -0
  21. package/src/providers/gql/RoleGqlProvider.ts +74 -0
  22. package/src/providers/gql/UserGqlProvider.ts +63 -0
  23. package/src/providers/rest/AuthRestProvider.ts +51 -0
  24. package/src/providers/rest/RoleRestProvider.ts +61 -0
  25. package/src/providers/rest/UserRestProvider.ts +55 -0
  26. package/src/system/AuthSystem.ts +35 -0
  27. package/src/system/RoleSystem.ts +43 -0
  28. package/src/system/UserSystem.ts +41 -0
  29. package/src/assets/base.css +0 -86
  30. package/src/assets/logo.svg +0 -1
  31. package/src/assets/main.css +0 -35
  32. package/src/components/HelloWorld.vue +0 -41
  33. package/src/components/IdentityLogin/IdentityLogin.vue +0 -82
  34. package/src/components/__tests__/IdentityLogin.spec.ts +0 -11
  35. package/src/components/icons/IconCommunity.vue +0 -7
  36. package/src/components/icons/IconDocumentation.vue +0 -0
  37. package/src/components/icons/IconEcosystem.vue +0 -0
  38. package/src/components/icons/IconSupport.vue +0 -0
  39. package/src/components/icons/IconTooling.vue +0 -0
  40. package/src/core/factories/providers/AuthProviderFactory.ts +0 -28
  41. package/src/core/interfaces/IAuthProviderInterface.ts +0 -5
  42. package/src/core/providers/gql/AuthGqlProvider.ts +0 -19
  43. package/src/core/providers/rest/AuthRestProvider.ts +0 -19
  44. package/src/core/system/AuthSystem.ts +0 -21
  45. package/src/stores/auth/AuthStore.ts +0 -19
  46. package/src/stores/counter.ts +0 -12
@@ -0,0 +1,74 @@
1
+ import type {IGqlClient, IPaginateClient} from '@drax/common-front'
2
+ import type {IRoleProvider} from "../../interfaces/IRoleProvider";
3
+ import type {IRole} from "../../interfaces/IRole";
4
+
5
+
6
+ class RoleGqlProvider implements IRoleProvider {
7
+
8
+ gqlClient: IGqlClient
9
+
10
+ constructor(gqlClient: IGqlClient) {
11
+ this.gqlClient = gqlClient
12
+ }
13
+
14
+ setHttpClientToken(token: string): void {
15
+ this.gqlClient.addHeader('Authorization', `Bearer ${token}`)
16
+ }
17
+
18
+ removeHttpClientToken(): void {
19
+ this.gqlClient.removeHeader('Authorization')
20
+ }
21
+
22
+ async fetchPermissions(): Promise<any> {
23
+ const query: string = `query fetchPermissions { fetchPermissions }`
24
+ const variables = {}
25
+ let data = await this.gqlClient.query(query, variables)
26
+ return data.fetchPermissions
27
+ }
28
+
29
+ async fetchRole(): Promise<any> {
30
+ const query: string = `query fetchRole { fetchRole { id name permissions readonly } }`
31
+ const variables = {}
32
+ let data = await this.gqlClient.query(query, variables)
33
+ return data.fetchRole
34
+ }
35
+
36
+ async createRole(payload: IRole): Promise<any> {
37
+ const query: string = `mutation createRole($input: RoleInput) {
38
+ createRole(input: $input) {id name permissions readonly }
39
+ }`
40
+ const variables = {input: payload}
41
+ let data = await this.gqlClient.mutation(query, variables)
42
+ return data.createRole
43
+ }
44
+
45
+ async editRole(id: string, payload: IRole): Promise<IRole> {
46
+ const query: string = `mutation updateRole($id: ID!, $input: RoleInput) { updateRole(id: $id, input: $input) {
47
+ id name permissions readonly } }`
48
+ const variables = {id, input: payload}
49
+ let data = await this.gqlClient.mutation(query, variables)
50
+ return data.createRole
51
+ }
52
+
53
+ async deleteRole(id: string): Promise<any> {
54
+ const query: string = `mutation deleteRole($id: ID!) { deleteRole(id: $id) }`
55
+ const variables = {id: id}
56
+ let data = await this.gqlClient.mutation(query, variables)
57
+ return data.createRole
58
+ }
59
+
60
+ async paginateRole(page: number, limit: number, search:string = ""): Promise<IPaginateClient> {
61
+ const query: string = `query paginateRole($page: Int, $limit: Int, $search:String) {
62
+ paginateRole(page: $page, limit: $limit, search: $search) {
63
+ total, page, limit, items{id, name , permissions, readonly }
64
+ }
65
+ }`
66
+ const variables = {page, limit,search}
67
+ let data = await this.gqlClient.query(query, variables)
68
+ return data.paginateRole
69
+ }
70
+
71
+
72
+ }
73
+
74
+ export default RoleGqlProvider
@@ -0,0 +1,63 @@
1
+ import type {IGqlClient, IPaginateClient} from '@drax/common-front'
2
+ import type {IUserProvider} from "../../interfaces/IUserProvider";
3
+ import type {IUser, IUserCreate, IUserPassword, IUserUpdate} from "../../interfaces/IUser";
4
+
5
+ class UserGqlProvider implements IUserProvider {
6
+
7
+ gqlClient: IGqlClient
8
+
9
+ constructor(gqlClient: IGqlClient) {
10
+ this.gqlClient = gqlClient
11
+ }
12
+
13
+ setHttpClientToken(token: string): void {
14
+ this.gqlClient.addHeader('Authorization', `Bearer ${token}`)
15
+ }
16
+
17
+ removeHttpClientToken(): void {
18
+ this.gqlClient.removeHeader('Authorization')
19
+ }
20
+
21
+ async createUser(payload: IUserCreate): Promise<IUser> {
22
+ const query: string = `mutation createUser($input: UserCreateInput) { createUser(input: $input) {
23
+ id username name email phone active role{id name} } }`
24
+ const variables = {input: payload}
25
+ let data = await this.gqlClient.mutation(query, variables)
26
+ return data.createUser
27
+ }
28
+
29
+ async editUser(id: string, payload: IUserUpdate): Promise<IUser> {
30
+ const query: string = `mutation updateUser($id: ID!, $input: UserUpdateInput) { updateUser(id: $id, input: $input) {
31
+ id username name email phone active role{id name} } }`
32
+ const variables = {id, input: payload}
33
+ let data = await this.gqlClient.mutation(query, variables)
34
+ return data.createUser
35
+ }
36
+
37
+ async changeUserPassword(userId: string, newPassword: string): Promise<boolean> {
38
+ const query: string = `mutation changeUserPassword($userId: ID!, $newPassword: String!) { changeUserPassword(userId:$userId, newPassword: $newPassword) }`
39
+ const variables = {userId, newPassword}
40
+ let data = await this.gqlClient.mutation(query, variables)
41
+ return data.changeUserPassword
42
+ }
43
+
44
+ async deleteUser(id: string): Promise<any> {
45
+ const query: string = `mutation deleteUser($id: ID!) { deleteUser(id: $id) }`
46
+ const variables = {id: id}
47
+ let data = await this.gqlClient.mutation(query, variables)
48
+ return data.createUser
49
+ }
50
+
51
+ async paginateUser(page: number, limit: number, search:string = ""): Promise<IPaginateClient> {
52
+ const query: string = `query paginateUser($page: Int, $limit: Int, $search:String) {
53
+ paginateUser(page: $page, limit: $limit, search: $search) {
54
+ total, page, limit, items{ id, name username, email, phone, active, role{id, name} }
55
+ }
56
+ }`
57
+ const variables = {page, limit, search}
58
+ let data = await this.gqlClient.query(query, variables)
59
+ return data.paginateUser
60
+ }
61
+ }
62
+
63
+ export default UserGqlProvider
@@ -0,0 +1,51 @@
1
+
2
+ import type {IHttpClient} from '@drax/common-front'
3
+ import type {IAuthProvider} from "../../interfaces/IAuthProvider";
4
+ import type {IAuthUser} from "../../interfaces/IAuthUser";
5
+ import type {ILoginResponse} from "../../interfaces/ILoginResponse";
6
+
7
+
8
+ class AuthRestProvider implements IAuthProvider {
9
+
10
+ httpClient: IHttpClient
11
+
12
+ constructor(httpClient: IHttpClient) {
13
+ this.httpClient = httpClient
14
+ }
15
+
16
+ setHttpClientToken(token: string): void {
17
+ this.httpClient.addHeader('Authorization', `Bearer ${token}`)
18
+ }
19
+
20
+ removeHttpClientToken(): void {
21
+ this.httpClient.removeHeader('Authorization')
22
+ }
23
+
24
+ async login(username: string, password: string): Promise<ILoginResponse> {
25
+ const url = '/api/auth'
26
+ const data = {username, password}
27
+ let {accessToken} = await this.httpClient.post(url, data) as ILoginResponse
28
+ this.setHttpClientToken(accessToken)
29
+ return {accessToken}
30
+ }
31
+
32
+ logout(): void {
33
+ this.removeHttpClientToken()
34
+ }
35
+
36
+ async me(): Promise<IAuthUser> {
37
+ const url = '/api/me'
38
+ let r = await this.httpClient.get(url) as IAuthUser
39
+ return r
40
+ }
41
+
42
+ async changeOwnPassword(currentPassword: string, newPassword: string): Promise<boolean> {
43
+ const url = '/api/password'
44
+ const data = {currentPassword, newPassword}
45
+ let r = await this.httpClient.post(url, data)
46
+ return /true/i.test(r as string)
47
+ }
48
+ }
49
+
50
+ export default AuthRestProvider
51
+ export {AuthRestProvider}
@@ -0,0 +1,61 @@
1
+ import type {IHttpClient, IPaginateClient} from '@drax/common-front'
2
+ import type {IRoleProvider} from "../../interfaces/IRoleProvider.ts";
3
+ import type {IRole} from "../../interfaces/IRole";
4
+
5
+ class RoleRestProvider implements IRoleProvider {
6
+
7
+ httpClient: IHttpClient
8
+
9
+ constructor(httpClient: IHttpClient) {
10
+ this.httpClient = httpClient
11
+ }
12
+
13
+ setHttpClientToken(token: string): void {
14
+ this.httpClient.addHeader('Authorization', `Bearer ${token}`)
15
+ }
16
+
17
+ removeHttpClientToken(): void {
18
+ this.httpClient.removeHeader('Authorization')
19
+ }
20
+
21
+ async fetchPermissions(): Promise<any> {
22
+ const url = '/api/permissions'
23
+ let permissions = await this.httpClient.get(url)
24
+ return permissions
25
+ }
26
+
27
+ async fetchRole(): Promise<any> {
28
+ const url = '/api/roles/all'
29
+ let role = await this.httpClient.get(url)
30
+ return role
31
+ }
32
+
33
+ async createRole(data: IRole): Promise<any> {
34
+ const url = '/api/roles'
35
+ let role = await this.httpClient.post(url, data)
36
+ return role
37
+ }
38
+ async editRole(id: string, data: IRole): Promise<IRole> {
39
+ const url = '/api/roles/' + id
40
+ let user = await this.httpClient.put(url, data)
41
+ return user as IRole
42
+ }
43
+
44
+ async deleteRole(id: string): Promise<any> {
45
+ const url = '/api/roles/' + id
46
+ let user = await this.httpClient.delete(url)
47
+ return user
48
+ }
49
+
50
+ async paginateRole(page: number = 1, limit: number = 5, search:string=""): Promise<IPaginateClient> {
51
+ const url = '/api/roles'
52
+ const params = {page, limit, search}
53
+ let paginatedRoles = await this.httpClient.get(url, {params})
54
+ return paginatedRoles as IPaginateClient
55
+
56
+ }
57
+
58
+
59
+ }
60
+
61
+ export default RoleRestProvider
@@ -0,0 +1,55 @@
1
+ import type {IHttpClient, IPaginateClient} from '@drax/common-front'
2
+ import type {IUserProvider} from "../../interfaces/IUserProvider.ts";
3
+ import type {IUser, IUserCreate, IUserUpdate} from "../../interfaces/IUser.ts";
4
+
5
+ class UserRestProvider implements IUserProvider {
6
+
7
+ httpClient: IHttpClient
8
+
9
+ constructor(httpClient: IHttpClient) {
10
+ this.httpClient = httpClient
11
+ }
12
+
13
+ setHttpClientToken(token: string): void {
14
+ this.httpClient.addHeader('Authorization', `Bearer ${token}`)
15
+ }
16
+
17
+ removeHttpClientToken(): void {
18
+ this.httpClient.removeHeader('Authorization')
19
+ }
20
+
21
+ async createUser(data: IUserCreate): Promise<IUser> {
22
+ const url = '/api/users'
23
+ let user = await this.httpClient.post(url, data)
24
+ return user as IUser
25
+ }
26
+
27
+ async editUser(id: string, data: IUserUpdate): Promise<IUser> {
28
+ const url = '/api/users/' + id
29
+ let user = await this.httpClient.put(url, data)
30
+ return user as IUser
31
+ }
32
+
33
+ async deleteUser(id: string): Promise<any> {
34
+ const url = '/api/users/' + id
35
+ let user = await this.httpClient.delete(url)
36
+ return user
37
+ }
38
+
39
+ async paginateUser(page: number = 1, limit: number = 5, search:string = ""): Promise<IPaginateClient> {
40
+ const url = '/api/users'
41
+ const params = {page, limit, search}
42
+ let paginatedUsers = await this.httpClient.get(url, {params})
43
+ return paginatedUsers as IPaginateClient
44
+
45
+ }
46
+
47
+ async changeUserPassword(userId: string, newPassword: string): Promise<boolean> {
48
+ const url = '/api/password/' + userId
49
+ const data = {userId, newPassword}
50
+ let r = await this.httpClient.post(url, data)
51
+ return /true/i.test(r as string)
52
+ }
53
+ }
54
+
55
+ export default UserRestProvider
@@ -0,0 +1,35 @@
1
+ import type {IAuthProvider} from "../interfaces/IAuthProvider.ts";
2
+ import type {IAuthUser} from "@/interfaces/IAuthUser";
3
+ import type {ILoginResponse} from "@/interfaces/ILoginResponse";
4
+
5
+ class AuthSystem {
6
+
7
+ _provider : IAuthProvider
8
+ prototype: string;
9
+ constructor(provider:IAuthProvider) {
10
+ this._provider = provider;
11
+ this.prototype = 'AuthSystem'
12
+ }
13
+
14
+ async login(username:string, password:string):Promise<ILoginResponse> {
15
+ const r = await this._provider.login(username, password)
16
+ return r
17
+ }
18
+
19
+ logout():void {
20
+ this._provider.logout()
21
+ }
22
+
23
+ async me():Promise<IAuthUser> {
24
+ const authUser: IAuthUser = await this._provider.me()
25
+ return authUser
26
+ }
27
+
28
+ async changeOwnPassword(currentPassword:string, newPassword:string):Promise<boolean> {
29
+ const result: boolean = await this._provider.changeOwnPassword(currentPassword,newPassword)
30
+ return result
31
+ }
32
+ }
33
+
34
+ export default AuthSystem
35
+ export {AuthSystem}
@@ -0,0 +1,43 @@
1
+ import type {IRoleProvider} from "@/interfaces/IRoleProvider";
2
+ import type {IRole} from "@/interfaces/IRole";
3
+ import type {IPaginateClient} from "@drax/common-front";
4
+
5
+
6
+ class RoleSystem {
7
+
8
+ _provider: IRoleProvider
9
+ prototype: string;
10
+
11
+ constructor(provider: IRoleProvider) {
12
+ this._provider = provider;
13
+ this.prototype = 'RoleSystem'
14
+ }
15
+
16
+ fetchRole():Promise<any> {
17
+ return this._provider.fetchRole()
18
+ }
19
+
20
+ fetchPermissions():Promise<any> {
21
+ return this._provider.fetchPermissions()
22
+ }
23
+
24
+ async paginateRole(page:number = 1, perPage:number = 5, search:string=""):Promise<IPaginateClient> {
25
+ return this._provider.paginateRole(page, perPage,search)
26
+ }
27
+
28
+ async createRole(userPayload: IRole):Promise<IRole> {
29
+ return this._provider.createRole(userPayload)
30
+ }
31
+
32
+ async editRole(id:string, userPayload: IRole):Promise<IRole> {
33
+ return this._provider.editRole(id, userPayload)
34
+ }
35
+
36
+ async deleteRole(id: string):Promise<any> {
37
+ return this._provider.deleteRole(id)
38
+ }
39
+
40
+ }
41
+
42
+ export default RoleSystem
43
+ export {RoleSystem}
@@ -0,0 +1,41 @@
1
+ import type {IUserProvider} from "@/interfaces/IUserProvider";
2
+ import type {IUser, IUserCreate, IUserUpdate} from "@/interfaces/IUser";
3
+ import type {IPaginateClient} from "@drax/common-front";
4
+
5
+
6
+ class UserSystem {
7
+
8
+ _provider: IUserProvider
9
+ prototype: string;
10
+
11
+ constructor(provider: IUserProvider) {
12
+ this._provider = provider;
13
+ this.prototype = 'UserSystem'
14
+ }
15
+
16
+ async paginateUser(page:number = 1, perPage:number = 5, search:string=""):Promise<IPaginateClient> {
17
+ return this._provider.paginateUser(page, perPage, search)
18
+ }
19
+
20
+ async createUser(userPayload: IUserCreate):Promise<IUser> {
21
+ return this._provider.createUser(userPayload)
22
+ }
23
+
24
+ async editUser(id:string, userPayload: IUserUpdate):Promise<IUser> {
25
+ return this._provider.editUser(id, userPayload)
26
+ }
27
+
28
+ async changeUserPassword(userId:string, newPassword:string):Promise<boolean> {
29
+ console.log("UserSystem",userId, newPassword)
30
+ const result: boolean = await this._provider.changeUserPassword(userId,newPassword)
31
+ return result
32
+ }
33
+
34
+ async deleteUser(id: string):Promise<any> {
35
+ return this._provider.deleteUser(id)
36
+ }
37
+
38
+ }
39
+
40
+ export default UserSystem
41
+ export {UserSystem}
@@ -1,86 +0,0 @@
1
- /* color palette from <https://github.com/vuejs/theme> */
2
- :root {
3
- --vt-c-white: #ffffff;
4
- --vt-c-white-soft: #f8f8f8;
5
- --vt-c-white-mute: #f2f2f2;
6
-
7
- --vt-c-black: #181818;
8
- --vt-c-black-soft: #222222;
9
- --vt-c-black-mute: #282828;
10
-
11
- --vt-c-indigo: #2c3e50;
12
-
13
- --vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
14
- --vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
15
- --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
16
- --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
17
-
18
- --vt-c-text-light-1: var(--vt-c-indigo);
19
- --vt-c-text-light-2: rgba(60, 60, 60, 0.66);
20
- --vt-c-text-dark-1: var(--vt-c-white);
21
- --vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
22
- }
23
-
24
- /* semantic color variables for this project */
25
- :root {
26
- --color-background: var(--vt-c-white);
27
- --color-background-soft: var(--vt-c-white-soft);
28
- --color-background-mute: var(--vt-c-white-mute);
29
-
30
- --color-border: var(--vt-c-divider-light-2);
31
- --color-border-hover: var(--vt-c-divider-light-1);
32
-
33
- --color-heading: var(--vt-c-text-light-1);
34
- --color-text: var(--vt-c-text-light-1);
35
-
36
- --section-gap: 160px;
37
- }
38
-
39
- @media (prefers-color-scheme: dark) {
40
- :root {
41
- --color-background: var(--vt-c-black);
42
- --color-background-soft: var(--vt-c-black-soft);
43
- --color-background-mute: var(--vt-c-black-mute);
44
-
45
- --color-border: var(--vt-c-divider-dark-2);
46
- --color-border-hover: var(--vt-c-divider-dark-1);
47
-
48
- --color-heading: var(--vt-c-text-dark-1);
49
- --color-text: var(--vt-c-text-dark-2);
50
- }
51
- }
52
-
53
- *,
54
- *::before,
55
- *::after {
56
- box-sizing: border-box;
57
- margin: 0;
58
- font-weight: normal;
59
- }
60
-
61
- body {
62
- min-height: 100vh;
63
- color: var(--color-text);
64
- background: var(--color-background);
65
- transition:
66
- color 0.5s,
67
- background-color 0.5s;
68
- line-height: 1.6;
69
- font-family:
70
- Inter,
71
- -apple-system,
72
- BlinkMacSystemFont,
73
- 'Segoe UI',
74
- Roboto,
75
- Oxygen,
76
- Ubuntu,
77
- Cantarell,
78
- 'Fira Sans',
79
- 'Droid Sans',
80
- 'Helvetica Neue',
81
- sans-serif;
82
- font-size: 15px;
83
- text-rendering: optimizeLegibility;
84
- -webkit-font-smoothing: antialiased;
85
- -moz-osx-font-smoothing: grayscale;
86
- }
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>
@@ -1,35 +0,0 @@
1
- @import './base.css';
2
-
3
- #app {
4
- max-width: 1280px;
5
- margin: 0 auto;
6
- padding: 2rem;
7
- font-weight: normal;
8
- }
9
-
10
- a,
11
- .green {
12
- text-decoration: none;
13
- color: hsla(160, 100%, 37%, 1);
14
- transition: 0.4s;
15
- padding: 3px;
16
- }
17
-
18
- @media (hover: hover) {
19
- a:hover {
20
- background-color: hsla(160, 100%, 37%, 0.2);
21
- }
22
- }
23
-
24
- @media (min-width: 1024px) {
25
- body {
26
- display: flex;
27
- place-items: center;
28
- }
29
-
30
- #app {
31
- display: grid;
32
- grid-template-columns: 1fr 1fr;
33
- padding: 0 2rem;
34
- }
35
- }
@@ -1,41 +0,0 @@
1
- <script setup lang="ts">
2
- defineProps<{
3
- msg: string
4
- }>()
5
- </script>
6
-
7
- <template>
8
- <div class="greetings">
9
- <h1 class="green">{{ msg }}</h1>
10
- <h3>
11
- You’ve successfully created a project with
12
- <a href="https://vitejs.dev/" target="_blank" rel="noopener">Vite</a> +
13
- <a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>.
14
- </h3>
15
- </div>
16
- </template>
17
-
18
- <style scoped>
19
- h1 {
20
- font-weight: 500;
21
- font-size: 2.6rem;
22
- position: relative;
23
- top: -10px;
24
- }
25
-
26
- h3 {
27
- font-size: 1.2rem;
28
- }
29
-
30
- .greetings h1,
31
- .greetings h3 {
32
- text-align: center;
33
- }
34
-
35
- @media (min-width: 1024px) {
36
- .greetings h1,
37
- .greetings h3 {
38
- text-align: left;
39
- }
40
- }
41
- </style>
@@ -1,82 +0,0 @@
1
- <script setup lang="ts">
2
- import { ref, computed, defineProps } from 'vue'
3
- import {useAuthStore} from "../../stores/auth/AuthStore.js";
4
-
5
- const {getAuthSystem} = useAuthStore()
6
-
7
- // Define props for customizing labels, title, and button text
8
- const props = defineProps({
9
- title: {
10
- type: String,
11
- default: 'Login'
12
- },
13
- usernameLabel: {
14
- type: String,
15
- default: 'Username'
16
- },
17
- passwordLabel: {
18
- type: String,
19
- default: 'Password'
20
- },
21
- buttonText: {
22
- type: String,
23
- default: 'Login'
24
- }
25
- })
26
-
27
- // Define reactive variables for form inputs
28
- const username = ref('')
29
- const password = ref('')
30
-
31
- // Compute whether the form is valid (both username and password are not empty)
32
- const isFormValid = computed(() => username.value.trim() !== '' && password.value.trim() !== '')
33
-
34
- // Function to handle form submission
35
- const submitForm = () => {
36
- console.log('Submitting:', { username: username.value, password: password.value })
37
- getAuthSystem?.login(username.value, password.value)
38
- // Here you would typically send the data to your backend
39
- }
40
- </script>
41
-
42
- <template>
43
- <v-container>
44
- <v-row justify="center">
45
- <v-col cols="12" sm="8" md="6" lg="5" xl="4" >
46
- <v-form @submit.prevent="submitForm">
47
- <v-card variant="tonal">
48
- <v-card-title>{{ props.title }}</v-card-title>
49
- <v-card-text>
50
- <v-text-field
51
- id="username-input"
52
- v-model="username"
53
- :label="props.usernameLabel"
54
- required
55
- ></v-text-field>
56
- <v-text-field
57
- id="password-input"
58
- v-model="password"
59
- :label="props.passwordLabel"
60
- type="password"
61
- required
62
- ></v-text-field>
63
- </v-card-text>
64
- <v-card-actions>
65
- <v-spacer></v-spacer>
66
- <v-btn
67
- id="submit-button"
68
- type="submit"
69
- color="primary"
70
- :disabled="!isFormValid"
71
- >{{ props.buttonText }}</v-btn>
72
- </v-card-actions>
73
- </v-card>
74
- </v-form>
75
- </v-col>
76
- </v-row>
77
- </v-container>
78
- </template>
79
-
80
- <style scoped lang="sass">
81
- // Your styles here
82
- </style>
@@ -1,11 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
-
3
- import { mount } from '@vue/test-utils'
4
- import IdentityLogin from '../IdentityLogin/IdentityLogin.vue'
5
-
6
- describe('IdentityLogin', () => {
7
- it('renders properly', () => {
8
- const wrapper = mount(IdentityLogin, { props: { msg: 'Hello Vitest' } })
9
- expect(wrapper.text()).toContain('Hello Vitest')
10
- })
11
- })