@sparkle-learning/core 0.0.63 → 0.0.65
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/dist/cjs/{PrivateRoute-f97245ce.js → PrivateRoute-475e69ce.js} +35 -0
- package/dist/cjs/header-mobile-collapse_61.cjs.entry.js +35 -27
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/sparkle-feedback.cjs.entry.js +1 -1
- package/dist/cjs/{student.service-7e5385be.js → student.service-6a085b00.js} +18 -16
- package/dist/collection/components/sparkle-login/sparkle-login.css +15 -4
- package/dist/collection/components/sparkle-login/sparkle-login.js +33 -28
- package/dist/collection/services/auth/auth.service.js +35 -0
- package/dist/collection/services/student.service.js +18 -16
- package/dist/esm/{PrivateRoute-90ac95b8.js → PrivateRoute-c83727f9.js} +35 -0
- package/dist/esm/header-mobile-collapse_61.entry.js +35 -27
- package/dist/esm/index.js +1 -1
- package/dist/esm/sparkle-feedback.entry.js +1 -1
- package/dist/esm/{student.service-08af124f.js → student.service-12d66503.js} +18 -16
- package/dist/sparkle-core/index.esm.js +1 -1
- package/dist/sparkle-core/p-3d81e425.js +1 -0
- package/dist/sparkle-core/{p-4d1cfcbe.entry.js → p-5c333142.entry.js} +1 -1
- package/dist/sparkle-core/{p-257f7bfd.entry.js → p-5de1651a.entry.js} +8 -8
- package/dist/sparkle-core/p-a6788e13.js +1 -0
- package/dist/sparkle-core/sparkle-core.esm.js +1 -1
- package/dist/types/components/sparkle-login/sparkle-login.d.ts +2 -2
- package/dist/types/services/auth/auth.service.d.ts +4 -0
- package/dist/types/services/student.service.d.ts +1 -1
- package/package.json +1 -1
- package/dist/sparkle-core/p-c9f753a4.js +0 -1
- package/dist/sparkle-core/p-e0cad1bb.js +0 -1
@@ -172,6 +172,41 @@ class AuthService {
|
|
172
172
|
return e;
|
173
173
|
}
|
174
174
|
}
|
175
|
+
async googleAuthenticate(authenticationInput) {
|
176
|
+
const headers = {
|
177
|
+
'Content-Type': 'application/json',
|
178
|
+
};
|
179
|
+
auth_store.AuthStore.state.loading = true;
|
180
|
+
let result;
|
181
|
+
try {
|
182
|
+
result = await httpService.HttpService.http.post('api/Account/googleAuthenticate', authenticationInput, {
|
183
|
+
headers: headers,
|
184
|
+
});
|
185
|
+
if (result) {
|
186
|
+
const authData = result.Data;
|
187
|
+
const authUser = {
|
188
|
+
Id: authData.Id,
|
189
|
+
UserName: authData.UserName,
|
190
|
+
Email: authData.Email,
|
191
|
+
Roles: authData.Roles,
|
192
|
+
IsVerified: authData.IsVerified,
|
193
|
+
JWToken: authData.JWToken,
|
194
|
+
IssuedOn: authData.IssuedOn,
|
195
|
+
ExpiresOn: authData.ExpiresOn,
|
196
|
+
RefreshToken: authData.RefreshToken,
|
197
|
+
PhotoUrl: '',
|
198
|
+
IsFacilitator: authData.Roles.indexOf('Facilitator') > 0,
|
199
|
+
};
|
200
|
+
await token_service.TokenService.getInstance().saveAuthUser(authUser);
|
201
|
+
auth_store.AuthStore.state.loading = false;
|
202
|
+
return authUser;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
catch (e) {
|
206
|
+
auth_store.AuthStore.state.loading = false;
|
207
|
+
return e;
|
208
|
+
}
|
209
|
+
}
|
175
210
|
async signOut() {
|
176
211
|
await localstorage_service.remove(token_service.AppConsts.AUTH_USER_LOCALSTORAGE);
|
177
212
|
await token_service.TokenService.getInstance().removeAuthUser();
|
@@ -13,10 +13,10 @@ const index$3 = require('./index-9c7b27e4.js');
|
|
13
13
|
const dir = require('./dir-5af5259a.js');
|
14
14
|
const spinnerConfigs = require('./spinner-configs-0ac05f2d.js');
|
15
15
|
const activeRouter = require('./active-router-f9e18bd8.js');
|
16
|
-
const PrivateRoute = require('./PrivateRoute-
|
16
|
+
const PrivateRoute = require('./PrivateRoute-475e69ce.js');
|
17
17
|
const assets_service = require('./assets.service-bfa75092.js');
|
18
18
|
const auth_store = require('./auth.store-1e630a7d.js');
|
19
|
-
const student_service = require('./student.service-
|
19
|
+
const student_service = require('./student.service-6a085b00.js');
|
20
20
|
const environmentConfig_service = require('./environment-config.service-c8ff1f3d.js');
|
21
21
|
const util = require('./util-9035404f.js');
|
22
22
|
const facilitator_service = require('./facilitator.service-ff0e1659.js');
|
@@ -13052,7 +13052,7 @@ const SparkleHealth = class {
|
|
13052
13052
|
};
|
13053
13053
|
SparkleHealth.style = sparkleHealthCss;
|
13054
13054
|
|
13055
|
-
const sparkleLoginCss = "sparkle-login .list{margin-bottom:0}";
|
13055
|
+
const sparkleLoginCss = "sparkle-login .list{margin-bottom:0}.google-login-container{padding-top:16px}.google-login-container iframe{background-color:none;box-shadow:none}.google-btn{display:flex;justify-content:center}";
|
13056
13056
|
|
13057
13057
|
const PageLogin = class {
|
13058
13058
|
constructor(hostRef) {
|
@@ -13072,9 +13072,25 @@ const PageLogin = class {
|
|
13072
13072
|
};
|
13073
13073
|
this.submitted = false;
|
13074
13074
|
this.googleLoading = false;
|
13075
|
-
this.
|
13075
|
+
this.onLoginWithGoogle = async (response) => {
|
13076
13076
|
// handle JWT token inside response...
|
13077
13077
|
// https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions#handle_credential_response
|
13078
|
+
try {
|
13079
|
+
this.googleLoading = true;
|
13080
|
+
console.log(response);
|
13081
|
+
if (response.credential) {
|
13082
|
+
let result = await PrivateRoute.AuthService.getInstance().googleAuthenticate({
|
13083
|
+
IdToken: response.credential,
|
13084
|
+
});
|
13085
|
+
console.log(result);
|
13086
|
+
// this.store.dispatch(
|
13087
|
+
// new fromRootStore.LoginWithGoogle(response.credential)
|
13088
|
+
// );
|
13089
|
+
}
|
13090
|
+
}
|
13091
|
+
catch (error) {
|
13092
|
+
this.googleLoading = false;
|
13093
|
+
}
|
13078
13094
|
};
|
13079
13095
|
}
|
13080
13096
|
handleUsername(ev) {
|
@@ -13110,28 +13126,20 @@ const PageLogin = class {
|
|
13110
13126
|
this.notsignin = !authUser;
|
13111
13127
|
});
|
13112
13128
|
this.notsignin = !auth_store.AuthStore.state.authUser;
|
13113
|
-
|
13114
|
-
|
13115
|
-
|
13116
|
-
|
13117
|
-
|
13118
|
-
|
13119
|
-
|
13120
|
-
|
13121
|
-
//
|
13122
|
-
|
13123
|
-
//
|
13124
|
-
|
13125
|
-
//
|
13126
|
-
|
13127
|
-
}
|
13128
|
-
onLoginWithGoogle(response) {
|
13129
|
-
try {
|
13130
|
-
this.googleLoading = true;
|
13131
|
-
}
|
13132
|
-
catch (error) {
|
13133
|
-
this.googleLoading = false;
|
13134
|
-
}
|
13129
|
+
}
|
13130
|
+
componentDidLoad() {
|
13131
|
+
google.accounts.id.initialize({
|
13132
|
+
client_id: '770507593736-s7m39gkms82ve9ev7n0jemrdfgafdteg.apps.googleusercontent.com',
|
13133
|
+
auto_select: false,
|
13134
|
+
callback: this.onLoginWithGoogle.bind(this),
|
13135
|
+
cancel_on_tap_outside: true,
|
13136
|
+
});
|
13137
|
+
// @ts-ignore
|
13138
|
+
google.accounts.id.renderButton(
|
13139
|
+
// @ts-ignore
|
13140
|
+
document.getElementById('google-button'), { theme: 'outline', size: 'large' });
|
13141
|
+
// @ts-ignore
|
13142
|
+
google.accounts.id.prompt((notification) => { });
|
13135
13143
|
}
|
13136
13144
|
disconnectedCallback() {
|
13137
13145
|
if (this.destroyListener) {
|
@@ -13163,7 +13171,7 @@ const PageLogin = class {
|
|
13163
13171
|
}
|
13164
13172
|
renderLogin() {
|
13165
13173
|
return [
|
13166
|
-
index.h("div", null, index.h("div", { class: "login-logo" }, index.h("img", { src: index.getAssetPath('/assets/img/G3-Girls.jpg'), alt: "Girls Inc" })), index.h("form", { novalidate: "true", onSubmit: e => this.onLogin(e) }, index.h("ion-list", { "no-lines": true }, index.h("ion-item", null, index.h("ion-label", { position: "stacked", color: "primary" }, "Username"), index.h("ion-input", { name: "username", type: "text", value: this.username.value, onInput: ev => this.handleUsername(ev), spellcheck: false, autocapitalize: "off", required: true })), index.h("ion-text", { color: "danger" }, index.h("p", { hidden: this.username.valid || this.submitted === false, class: "ion-padding-left" }, "Username is required")), index.h("ion-item", null, index.h("ion-label", { position: "stacked", color: "primary" }, "Password"), index.h("ion-input", { name: "password", type: "password", value: this.password.value, onInput: ev => this.handlePassword(ev), required: true })), index.h("ion-text", { color: "danger" }, index.h("p", { hidden: this.password.valid || this.submitted === false, class: "ion-padding-left" }, "Password is required")), index.h("ion-item", { lines: "none" }, index.h("ion-label", null, "Remember Me"), index.h("ion-checkbox", { slot: "start", checked: this.rememberMe.value, onIonChange: e => this.handleRememberMe(e) })), index.h("ion-item", { lines: "none" }, index.h("stencil-route-link", { slot: "end", url: "/forgot-password", exact: true }, "Forgot Password?"))), index.h("ion-row", null, index.h("ion-col", null, index.h("ion-button", { type: "submit", expand: "block", disabled: auth_store.AuthStore.state.loading }, auth_store.AuthStore.state.loading && index.h("ion-spinner", { name: "dots" }), " Log In"))), index.h("ion-item", { lines: "none" }, index.h("span", null, ' ', "Not registered yet?", ' ', index.h("stencil-route-link", { url: "/signup", exact: true }, "Sign Up"))))),
|
13174
|
+
index.h("div", null, index.h("div", { class: "login-logo" }, index.h("img", { src: index.getAssetPath('/assets/img/G3-Girls.jpg'), alt: "Girls Inc" })), index.h("form", { novalidate: "true", onSubmit: e => this.onLogin(e) }, index.h("ion-list", { "no-lines": true }, index.h("ion-item", null, index.h("ion-label", { position: "stacked", color: "primary" }, "Username"), index.h("ion-input", { name: "username", type: "text", value: this.username.value, onInput: ev => this.handleUsername(ev), spellcheck: false, autocapitalize: "off", required: true })), index.h("ion-text", { color: "danger" }, index.h("p", { hidden: this.username.valid || this.submitted === false, class: "ion-padding-left" }, "Username is required")), index.h("ion-item", null, index.h("ion-label", { position: "stacked", color: "primary" }, "Password"), index.h("ion-input", { name: "password", type: "password", value: this.password.value, onInput: ev => this.handlePassword(ev), required: true })), index.h("ion-text", { color: "danger" }, index.h("p", { hidden: this.password.valid || this.submitted === false, class: "ion-padding-left" }, "Password is required")), index.h("ion-item", { lines: "none" }, index.h("ion-label", null, "Remember Me"), index.h("ion-checkbox", { slot: "start", checked: this.rememberMe.value, onIonChange: e => this.handleRememberMe(e) })), index.h("ion-item", { lines: "none" }, index.h("stencil-route-link", { slot: "end", url: "/forgot-password", exact: true }, "Forgot Password?"))), index.h("ion-row", null, index.h("ion-col", null, index.h("ion-button", { type: "submit", expand: "block", disabled: auth_store.AuthStore.state.loading }, auth_store.AuthStore.state.loading && index.h("ion-spinner", { name: "dots" }), " Log In"))), index.h("ion-item", { lines: "none" }, index.h("span", null, ' ', "Not registered yet?", ' ', index.h("stencil-route-link", { url: "/signup", exact: true }, "Sign Up"))), index.h("div", { class: "google-login-container" }, index.h("div", { class: "google-btn", id: "google-button" })))),
|
13167
13175
|
];
|
13168
13176
|
}
|
13169
13177
|
render() {
|
package/dist/cjs/index.cjs.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
const PrivateRoute = require('./PrivateRoute-
|
5
|
+
const PrivateRoute = require('./PrivateRoute-475e69ce.js');
|
6
6
|
const environmentConfig_service = require('./environment-config.service-c8ff1f3d.js');
|
7
7
|
const assets_service = require('./assets.service-bfa75092.js');
|
8
8
|
const auth_store = require('./auth.store-1e630a7d.js');
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
5
|
const index = require('./index-51e8292e.js');
|
6
|
-
const student_service = require('./student.service-
|
6
|
+
const student_service = require('./student.service-6a085b00.js');
|
7
7
|
const overlays = require('./overlays-32df265a.js');
|
8
8
|
require('./httpService-d2e7bf8f.js');
|
9
9
|
require('./auth.store-1e630a7d.js');
|
@@ -30,33 +30,35 @@ class StudentService {
|
|
30
30
|
async enrollClass(enrollInput) {
|
31
31
|
let result = await httpService.HttpService.http.post('api/v1/Student/EnrollClass', enrollInput);
|
32
32
|
if (result) {
|
33
|
-
userStore.state.enrollmentList = [
|
34
|
-
...userStore.state.enrollmentList,
|
35
|
-
result.Data
|
36
|
-
];
|
33
|
+
userStore.state.enrollmentList = [...userStore.state.enrollmentList, result.Data];
|
37
34
|
}
|
38
35
|
return result;
|
39
36
|
}
|
40
37
|
async leaveClass(leaveInput) {
|
41
38
|
let result = await httpService.HttpService.http.post('api/v1/Student/LeaveClass', leaveInput);
|
42
39
|
if (result) {
|
43
|
-
userStore.state.enrollmentList = userStore.state.enrollmentList.filter(
|
40
|
+
userStore.state.enrollmentList = userStore.state.enrollmentList.filter(item => item.Id != result.Data);
|
44
41
|
}
|
45
42
|
return result;
|
46
43
|
}
|
47
44
|
async fetchUserConfiguration() {
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
45
|
+
try {
|
46
|
+
let result = await httpService.HttpService.http.get('api/v1/Student/UserConfiguration');
|
47
|
+
if (result) {
|
48
|
+
userStore.state.enrollmentList = result.Data.EnrollmentList;
|
49
|
+
userStore.state.user.FirstName = result.Data.FirstName;
|
50
|
+
userStore.state.user.LastName = result.Data.LastName;
|
51
|
+
userStore.state.user.ProfileText = result.Data.ProfileText;
|
52
|
+
userStore.state.user.ProfileImage = result.Data.ProfileImage;
|
53
|
+
userStore.state.user.IsVerified = result.Data.IsVerified;
|
54
|
+
userStore.state.user.Roles = result.Data.Roles;
|
55
|
+
userStore.state.user.FacilitatorClassList = result.Data.FacilitatorClassList;
|
56
|
+
}
|
57
|
+
return result;
|
58
|
+
}
|
59
|
+
catch (e) {
|
60
|
+
return null;
|
58
61
|
}
|
59
|
-
return result;
|
60
62
|
}
|
61
63
|
async updateProfile(updateProfileInput) {
|
62
64
|
userStore.state.updateLoading = true;
|
@@ -1,4 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
sparkle-login .list {
|
2
|
+
margin-bottom: 0;
|
3
|
+
}
|
4
|
+
.google-login-container {
|
5
|
+
padding-top: 16px;
|
6
|
+
}
|
7
|
+
|
8
|
+
.google-login-container iframe {
|
9
|
+
background-color: none;
|
10
|
+
box-shadow: none;
|
11
|
+
}
|
12
|
+
.google-btn {
|
13
|
+
display: flex;
|
14
|
+
justify-content: center;
|
15
|
+
}
|
@@ -17,9 +17,25 @@ export class PageLogin {
|
|
17
17
|
};
|
18
18
|
this.submitted = false;
|
19
19
|
this.googleLoading = false;
|
20
|
-
this.
|
20
|
+
this.onLoginWithGoogle = async (response) => {
|
21
21
|
// handle JWT token inside response...
|
22
22
|
// https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions#handle_credential_response
|
23
|
+
try {
|
24
|
+
this.googleLoading = true;
|
25
|
+
console.log(response);
|
26
|
+
if (response.credential) {
|
27
|
+
let result = await AuthService.getInstance().googleAuthenticate({
|
28
|
+
IdToken: response.credential,
|
29
|
+
});
|
30
|
+
console.log(result);
|
31
|
+
// this.store.dispatch(
|
32
|
+
// new fromRootStore.LoginWithGoogle(response.credential)
|
33
|
+
// );
|
34
|
+
}
|
35
|
+
}
|
36
|
+
catch (error) {
|
37
|
+
this.googleLoading = false;
|
38
|
+
}
|
23
39
|
};
|
24
40
|
}
|
25
41
|
handleUsername(ev) {
|
@@ -55,33 +71,20 @@ export class PageLogin {
|
|
55
71
|
this.notsignin = !authUser;
|
56
72
|
});
|
57
73
|
this.notsignin = !AuthStore.state.authUser;
|
58
|
-
// google.accounts.id.initialize({
|
59
|
-
// client_id: '770507593736-s7m39gkms82ve9ev7n0jemrdfgafdteg.apps.googleusercontent.com',
|
60
|
-
// auto_select: false,
|
61
|
-
// callback: this.googleLoginCallback,
|
62
|
-
// cancel_on_tap_outside: true,
|
63
|
-
// });
|
64
|
-
// // @ts-ignore
|
65
|
-
// google.accounts.id.renderButton(
|
66
|
-
// // @ts-ignore
|
67
|
-
// document.getElementById('google-button'),
|
68
|
-
// { theme: 'outline', size: 'large' },
|
69
|
-
// );
|
70
|
-
// // @ts-ignore
|
71
|
-
// google.accounts.id.prompt((notification: PromptMomentNotification) => {});
|
72
74
|
}
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
75
|
+
componentDidLoad() {
|
76
|
+
google.accounts.id.initialize({
|
77
|
+
client_id: '770507593736-s7m39gkms82ve9ev7n0jemrdfgafdteg.apps.googleusercontent.com',
|
78
|
+
auto_select: false,
|
79
|
+
callback: this.onLoginWithGoogle.bind(this),
|
80
|
+
cancel_on_tap_outside: true,
|
81
|
+
});
|
82
|
+
// @ts-ignore
|
83
|
+
google.accounts.id.renderButton(
|
84
|
+
// @ts-ignore
|
85
|
+
document.getElementById('google-button'), { theme: 'outline', size: 'large' });
|
86
|
+
// @ts-ignore
|
87
|
+
google.accounts.id.prompt((notification) => { });
|
85
88
|
}
|
86
89
|
disconnectedCallback() {
|
87
90
|
if (this.destroyListener) {
|
@@ -143,7 +146,9 @@ export class PageLogin {
|
|
143
146
|
' ',
|
144
147
|
"Not registered yet?",
|
145
148
|
' ',
|
146
|
-
h("stencil-route-link", { url: "/signup", exact: true }, "Sign Up")))
|
149
|
+
h("stencil-route-link", { url: "/signup", exact: true }, "Sign Up"))),
|
150
|
+
h("div", { class: "google-login-container" },
|
151
|
+
h("div", { class: "google-btn", id: "google-button" })))),
|
147
152
|
];
|
148
153
|
}
|
149
154
|
render() {
|
@@ -53,6 +53,41 @@ export class AuthService {
|
|
53
53
|
return e;
|
54
54
|
}
|
55
55
|
}
|
56
|
+
async googleAuthenticate(authenticationInput) {
|
57
|
+
const headers = {
|
58
|
+
'Content-Type': 'application/json',
|
59
|
+
};
|
60
|
+
AuthStore.state.loading = true;
|
61
|
+
let result;
|
62
|
+
try {
|
63
|
+
result = await HttpService.http.post('api/Account/googleAuthenticate', authenticationInput, {
|
64
|
+
headers: headers,
|
65
|
+
});
|
66
|
+
if (result) {
|
67
|
+
const authData = result.Data;
|
68
|
+
const authUser = {
|
69
|
+
Id: authData.Id,
|
70
|
+
UserName: authData.UserName,
|
71
|
+
Email: authData.Email,
|
72
|
+
Roles: authData.Roles,
|
73
|
+
IsVerified: authData.IsVerified,
|
74
|
+
JWToken: authData.JWToken,
|
75
|
+
IssuedOn: authData.IssuedOn,
|
76
|
+
ExpiresOn: authData.ExpiresOn,
|
77
|
+
RefreshToken: authData.RefreshToken,
|
78
|
+
PhotoUrl: '',
|
79
|
+
IsFacilitator: authData.Roles.indexOf('Facilitator') > 0,
|
80
|
+
};
|
81
|
+
await TokenService.getInstance().saveAuthUser(authUser);
|
82
|
+
AuthStore.state.loading = false;
|
83
|
+
return authUser;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
catch (e) {
|
87
|
+
AuthStore.state.loading = false;
|
88
|
+
return e;
|
89
|
+
}
|
90
|
+
}
|
56
91
|
async signOut() {
|
57
92
|
await remove(AppConsts.AUTH_USER_LOCALSTORAGE);
|
58
93
|
await TokenService.getInstance().removeAuthUser();
|
@@ -11,33 +11,35 @@ export class StudentService {
|
|
11
11
|
async enrollClass(enrollInput) {
|
12
12
|
let result = await HttpService.http.post('api/v1/Student/EnrollClass', enrollInput);
|
13
13
|
if (result) {
|
14
|
-
userStore.state.enrollmentList = [
|
15
|
-
...userStore.state.enrollmentList,
|
16
|
-
result.Data
|
17
|
-
];
|
14
|
+
userStore.state.enrollmentList = [...userStore.state.enrollmentList, result.Data];
|
18
15
|
}
|
19
16
|
return result;
|
20
17
|
}
|
21
18
|
async leaveClass(leaveInput) {
|
22
19
|
let result = await HttpService.http.post('api/v1/Student/LeaveClass', leaveInput);
|
23
20
|
if (result) {
|
24
|
-
userStore.state.enrollmentList = userStore.state.enrollmentList.filter(
|
21
|
+
userStore.state.enrollmentList = userStore.state.enrollmentList.filter(item => item.Id != result.Data);
|
25
22
|
}
|
26
23
|
return result;
|
27
24
|
}
|
28
25
|
async fetchUserConfiguration() {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
26
|
+
try {
|
27
|
+
let result = await HttpService.http.get('api/v1/Student/UserConfiguration');
|
28
|
+
if (result) {
|
29
|
+
userStore.state.enrollmentList = result.Data.EnrollmentList;
|
30
|
+
userStore.state.user.FirstName = result.Data.FirstName;
|
31
|
+
userStore.state.user.LastName = result.Data.LastName;
|
32
|
+
userStore.state.user.ProfileText = result.Data.ProfileText;
|
33
|
+
userStore.state.user.ProfileImage = result.Data.ProfileImage;
|
34
|
+
userStore.state.user.IsVerified = result.Data.IsVerified;
|
35
|
+
userStore.state.user.Roles = result.Data.Roles;
|
36
|
+
userStore.state.user.FacilitatorClassList = result.Data.FacilitatorClassList;
|
37
|
+
}
|
38
|
+
return result;
|
39
|
+
}
|
40
|
+
catch (e) {
|
41
|
+
return null;
|
39
42
|
}
|
40
|
-
return result;
|
41
43
|
}
|
42
44
|
async updateProfile(updateProfileInput) {
|
43
45
|
userStore.state.updateLoading = true;
|
@@ -170,6 +170,41 @@ class AuthService {
|
|
170
170
|
return e;
|
171
171
|
}
|
172
172
|
}
|
173
|
+
async googleAuthenticate(authenticationInput) {
|
174
|
+
const headers = {
|
175
|
+
'Content-Type': 'application/json',
|
176
|
+
};
|
177
|
+
AuthStore.state.loading = true;
|
178
|
+
let result;
|
179
|
+
try {
|
180
|
+
result = await HttpService.http.post('api/Account/googleAuthenticate', authenticationInput, {
|
181
|
+
headers: headers,
|
182
|
+
});
|
183
|
+
if (result) {
|
184
|
+
const authData = result.Data;
|
185
|
+
const authUser = {
|
186
|
+
Id: authData.Id,
|
187
|
+
UserName: authData.UserName,
|
188
|
+
Email: authData.Email,
|
189
|
+
Roles: authData.Roles,
|
190
|
+
IsVerified: authData.IsVerified,
|
191
|
+
JWToken: authData.JWToken,
|
192
|
+
IssuedOn: authData.IssuedOn,
|
193
|
+
ExpiresOn: authData.ExpiresOn,
|
194
|
+
RefreshToken: authData.RefreshToken,
|
195
|
+
PhotoUrl: '',
|
196
|
+
IsFacilitator: authData.Roles.indexOf('Facilitator') > 0,
|
197
|
+
};
|
198
|
+
await TokenService.getInstance().saveAuthUser(authUser);
|
199
|
+
AuthStore.state.loading = false;
|
200
|
+
return authUser;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
catch (e) {
|
204
|
+
AuthStore.state.loading = false;
|
205
|
+
return e;
|
206
|
+
}
|
207
|
+
}
|
173
208
|
async signOut() {
|
174
209
|
await remove(AppConsts.AUTH_USER_LOCALSTORAGE);
|
175
210
|
await TokenService.getInstance().removeAuthUser();
|
@@ -9,10 +9,10 @@ import { f as findClosestIonContent, d as disableContentScrollY, r as resetConte
|
|
9
9
|
import { i as isRTL } from './dir-03012648.js';
|
10
10
|
import { S as SPINNERS } from './spinner-configs-a37e628a.js';
|
11
11
|
import { A as ActiveRouter } from './active-router-fc9e4e06.js';
|
12
|
-
import { i as initSetupConfig, A as AuthService, P as PrivateRoute, s as setupConfig } from './PrivateRoute-
|
12
|
+
import { i as initSetupConfig, A as AuthService, P as PrivateRoute, s as setupConfig } from './PrivateRoute-c83727f9.js';
|
13
13
|
import { A as AssetsService } from './assets.service-def1d63c.js';
|
14
14
|
import { A as AuthStore, c as createCommonjsModule, g as getDefaultExportFromCjs, b as commonjsGlobal, T as TocStore } from './auth.store-dba2c2da.js';
|
15
|
-
import { u as userStore, S as StudentService } from './student.service-
|
15
|
+
import { u as userStore, S as StudentService } from './student.service-12d66503.js';
|
16
16
|
import { E as EnvironmentConfigService } from './environment-config.service-b191f276.js';
|
17
17
|
import { s as sample, S as SparkleGlobal$1, d as date, M as MyHealthTemplate, a as MyHealthTemplateJSON, b as MyMoodTemplate, c as MyMoodTemplateJSON } from './util-458c62fb.js';
|
18
18
|
import { F as FacilitatorService, f as facilitatorStore } from './facilitator.service-18c47bdf.js';
|
@@ -13048,7 +13048,7 @@ const SparkleHealth = class {
|
|
13048
13048
|
};
|
13049
13049
|
SparkleHealth.style = sparkleHealthCss;
|
13050
13050
|
|
13051
|
-
const sparkleLoginCss = "sparkle-login .list{margin-bottom:0}";
|
13051
|
+
const sparkleLoginCss = "sparkle-login .list{margin-bottom:0}.google-login-container{padding-top:16px}.google-login-container iframe{background-color:none;box-shadow:none}.google-btn{display:flex;justify-content:center}";
|
13052
13052
|
|
13053
13053
|
const PageLogin = class {
|
13054
13054
|
constructor(hostRef) {
|
@@ -13068,9 +13068,25 @@ const PageLogin = class {
|
|
13068
13068
|
};
|
13069
13069
|
this.submitted = false;
|
13070
13070
|
this.googleLoading = false;
|
13071
|
-
this.
|
13071
|
+
this.onLoginWithGoogle = async (response) => {
|
13072
13072
|
// handle JWT token inside response...
|
13073
13073
|
// https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions#handle_credential_response
|
13074
|
+
try {
|
13075
|
+
this.googleLoading = true;
|
13076
|
+
console.log(response);
|
13077
|
+
if (response.credential) {
|
13078
|
+
let result = await AuthService.getInstance().googleAuthenticate({
|
13079
|
+
IdToken: response.credential,
|
13080
|
+
});
|
13081
|
+
console.log(result);
|
13082
|
+
// this.store.dispatch(
|
13083
|
+
// new fromRootStore.LoginWithGoogle(response.credential)
|
13084
|
+
// );
|
13085
|
+
}
|
13086
|
+
}
|
13087
|
+
catch (error) {
|
13088
|
+
this.googleLoading = false;
|
13089
|
+
}
|
13074
13090
|
};
|
13075
13091
|
}
|
13076
13092
|
handleUsername(ev) {
|
@@ -13106,28 +13122,20 @@ const PageLogin = class {
|
|
13106
13122
|
this.notsignin = !authUser;
|
13107
13123
|
});
|
13108
13124
|
this.notsignin = !AuthStore.state.authUser;
|
13109
|
-
|
13110
|
-
|
13111
|
-
|
13112
|
-
|
13113
|
-
|
13114
|
-
|
13115
|
-
|
13116
|
-
|
13117
|
-
//
|
13118
|
-
|
13119
|
-
//
|
13120
|
-
|
13121
|
-
//
|
13122
|
-
|
13123
|
-
}
|
13124
|
-
onLoginWithGoogle(response) {
|
13125
|
-
try {
|
13126
|
-
this.googleLoading = true;
|
13127
|
-
}
|
13128
|
-
catch (error) {
|
13129
|
-
this.googleLoading = false;
|
13130
|
-
}
|
13125
|
+
}
|
13126
|
+
componentDidLoad() {
|
13127
|
+
google.accounts.id.initialize({
|
13128
|
+
client_id: '770507593736-s7m39gkms82ve9ev7n0jemrdfgafdteg.apps.googleusercontent.com',
|
13129
|
+
auto_select: false,
|
13130
|
+
callback: this.onLoginWithGoogle.bind(this),
|
13131
|
+
cancel_on_tap_outside: true,
|
13132
|
+
});
|
13133
|
+
// @ts-ignore
|
13134
|
+
google.accounts.id.renderButton(
|
13135
|
+
// @ts-ignore
|
13136
|
+
document.getElementById('google-button'), { theme: 'outline', size: 'large' });
|
13137
|
+
// @ts-ignore
|
13138
|
+
google.accounts.id.prompt((notification) => { });
|
13131
13139
|
}
|
13132
13140
|
disconnectedCallback() {
|
13133
13141
|
if (this.destroyListener) {
|
@@ -13159,7 +13167,7 @@ const PageLogin = class {
|
|
13159
13167
|
}
|
13160
13168
|
renderLogin() {
|
13161
13169
|
return [
|
13162
|
-
h$1("div", null, h$1("div", { class: "login-logo" }, h$1("img", { src: getAssetPath('/assets/img/G3-Girls.jpg'), alt: "Girls Inc" })), h$1("form", { novalidate: "true", onSubmit: e => this.onLogin(e) }, h$1("ion-list", { "no-lines": true }, h$1("ion-item", null, h$1("ion-label", { position: "stacked", color: "primary" }, "Username"), h$1("ion-input", { name: "username", type: "text", value: this.username.value, onInput: ev => this.handleUsername(ev), spellcheck: false, autocapitalize: "off", required: true })), h$1("ion-text", { color: "danger" }, h$1("p", { hidden: this.username.valid || this.submitted === false, class: "ion-padding-left" }, "Username is required")), h$1("ion-item", null, h$1("ion-label", { position: "stacked", color: "primary" }, "Password"), h$1("ion-input", { name: "password", type: "password", value: this.password.value, onInput: ev => this.handlePassword(ev), required: true })), h$1("ion-text", { color: "danger" }, h$1("p", { hidden: this.password.valid || this.submitted === false, class: "ion-padding-left" }, "Password is required")), h$1("ion-item", { lines: "none" }, h$1("ion-label", null, "Remember Me"), h$1("ion-checkbox", { slot: "start", checked: this.rememberMe.value, onIonChange: e => this.handleRememberMe(e) })), h$1("ion-item", { lines: "none" }, h$1("stencil-route-link", { slot: "end", url: "/forgot-password", exact: true }, "Forgot Password?"))), h$1("ion-row", null, h$1("ion-col", null, h$1("ion-button", { type: "submit", expand: "block", disabled: AuthStore.state.loading }, AuthStore.state.loading && h$1("ion-spinner", { name: "dots" }), " Log In"))), h$1("ion-item", { lines: "none" }, h$1("span", null, ' ', "Not registered yet?", ' ', h$1("stencil-route-link", { url: "/signup", exact: true }, "Sign Up"))))),
|
13170
|
+
h$1("div", null, h$1("div", { class: "login-logo" }, h$1("img", { src: getAssetPath('/assets/img/G3-Girls.jpg'), alt: "Girls Inc" })), h$1("form", { novalidate: "true", onSubmit: e => this.onLogin(e) }, h$1("ion-list", { "no-lines": true }, h$1("ion-item", null, h$1("ion-label", { position: "stacked", color: "primary" }, "Username"), h$1("ion-input", { name: "username", type: "text", value: this.username.value, onInput: ev => this.handleUsername(ev), spellcheck: false, autocapitalize: "off", required: true })), h$1("ion-text", { color: "danger" }, h$1("p", { hidden: this.username.valid || this.submitted === false, class: "ion-padding-left" }, "Username is required")), h$1("ion-item", null, h$1("ion-label", { position: "stacked", color: "primary" }, "Password"), h$1("ion-input", { name: "password", type: "password", value: this.password.value, onInput: ev => this.handlePassword(ev), required: true })), h$1("ion-text", { color: "danger" }, h$1("p", { hidden: this.password.valid || this.submitted === false, class: "ion-padding-left" }, "Password is required")), h$1("ion-item", { lines: "none" }, h$1("ion-label", null, "Remember Me"), h$1("ion-checkbox", { slot: "start", checked: this.rememberMe.value, onIonChange: e => this.handleRememberMe(e) })), h$1("ion-item", { lines: "none" }, h$1("stencil-route-link", { slot: "end", url: "/forgot-password", exact: true }, "Forgot Password?"))), h$1("ion-row", null, h$1("ion-col", null, h$1("ion-button", { type: "submit", expand: "block", disabled: AuthStore.state.loading }, AuthStore.state.loading && h$1("ion-spinner", { name: "dots" }), " Log In"))), h$1("ion-item", { lines: "none" }, h$1("span", null, ' ', "Not registered yet?", ' ', h$1("stencil-route-link", { url: "/signup", exact: true }, "Sign Up"))), h$1("div", { class: "google-login-container" }, h$1("div", { class: "google-btn", id: "google-button" })))),
|
13163
13171
|
];
|
13164
13172
|
}
|
13165
13173
|
render() {
|
package/dist/esm/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export { A as AuthService, P as PrivateRoute, i as initSetupEnvironmentConfig, s as setupEnvironmentConfig } from './PrivateRoute-
|
1
|
+
export { A as AuthService, P as PrivateRoute, i as initSetupEnvironmentConfig, s as setupEnvironmentConfig } from './PrivateRoute-c83727f9.js';
|
2
2
|
export { E as EnvironmentConfigService } from './environment-config.service-b191f276.js';
|
3
3
|
export { A as AssetsService } from './assets.service-def1d63c.js';
|
4
4
|
export { A as AuthStore } from './auth.store-dba2c2da.js';
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { r as registerInstance, h, H as Host, e as getElement } from './index-c04b9ed5.js';
|
2
|
-
import { S as StudentService } from './student.service-
|
2
|
+
import { S as StudentService } from './student.service-12d66503.js';
|
3
3
|
import { t as toastController } from './overlays-4233a39d.js';
|
4
4
|
import './httpService-7986aeed.js';
|
5
5
|
import './auth.store-dba2c2da.js';
|
@@ -28,33 +28,35 @@ class StudentService {
|
|
28
28
|
async enrollClass(enrollInput) {
|
29
29
|
let result = await HttpService.http.post('api/v1/Student/EnrollClass', enrollInput);
|
30
30
|
if (result) {
|
31
|
-
userStore.state.enrollmentList = [
|
32
|
-
...userStore.state.enrollmentList,
|
33
|
-
result.Data
|
34
|
-
];
|
31
|
+
userStore.state.enrollmentList = [...userStore.state.enrollmentList, result.Data];
|
35
32
|
}
|
36
33
|
return result;
|
37
34
|
}
|
38
35
|
async leaveClass(leaveInput) {
|
39
36
|
let result = await HttpService.http.post('api/v1/Student/LeaveClass', leaveInput);
|
40
37
|
if (result) {
|
41
|
-
userStore.state.enrollmentList = userStore.state.enrollmentList.filter(
|
38
|
+
userStore.state.enrollmentList = userStore.state.enrollmentList.filter(item => item.Id != result.Data);
|
42
39
|
}
|
43
40
|
return result;
|
44
41
|
}
|
45
42
|
async fetchUserConfiguration() {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
43
|
+
try {
|
44
|
+
let result = await HttpService.http.get('api/v1/Student/UserConfiguration');
|
45
|
+
if (result) {
|
46
|
+
userStore.state.enrollmentList = result.Data.EnrollmentList;
|
47
|
+
userStore.state.user.FirstName = result.Data.FirstName;
|
48
|
+
userStore.state.user.LastName = result.Data.LastName;
|
49
|
+
userStore.state.user.ProfileText = result.Data.ProfileText;
|
50
|
+
userStore.state.user.ProfileImage = result.Data.ProfileImage;
|
51
|
+
userStore.state.user.IsVerified = result.Data.IsVerified;
|
52
|
+
userStore.state.user.Roles = result.Data.Roles;
|
53
|
+
userStore.state.user.FacilitatorClassList = result.Data.FacilitatorClassList;
|
54
|
+
}
|
55
|
+
return result;
|
56
|
+
}
|
57
|
+
catch (e) {
|
58
|
+
return null;
|
56
59
|
}
|
57
|
-
return result;
|
58
60
|
}
|
59
61
|
async updateProfile(updateProfileInput) {
|
60
62
|
userStore.state.updateLoading = true;
|