@sparkstudio/authentication-ui 1.0.19 → 1.0.20
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/index.cjs +5 -3
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ var Auth = class {
|
|
|
41
41
|
}
|
|
42
42
|
async Logout() {
|
|
43
43
|
const url = `${this.baseUrl}/api/Auth/Logout`;
|
|
44
|
-
const token =
|
|
44
|
+
const token = localStorage.getItem("auth_token");
|
|
45
45
|
const requestOptions = {
|
|
46
46
|
method: "GET",
|
|
47
47
|
credentials: "include",
|
|
@@ -56,7 +56,7 @@ var Auth = class {
|
|
|
56
56
|
}
|
|
57
57
|
async GetCurrentUser() {
|
|
58
58
|
const url = `${this.baseUrl}/api/Auth/GetCurrentUser`;
|
|
59
|
-
const token =
|
|
59
|
+
const token = localStorage.getItem("auth_token");
|
|
60
60
|
const requestOptions = {
|
|
61
61
|
method: "GET",
|
|
62
62
|
credentials: "include",
|
|
@@ -71,7 +71,7 @@ var Auth = class {
|
|
|
71
71
|
}
|
|
72
72
|
async SignIn(tokenRequest) {
|
|
73
73
|
const url = `${this.baseUrl}/api/Auth/SignIn`;
|
|
74
|
-
const token =
|
|
74
|
+
const token = localStorage.getItem("auth_token");
|
|
75
75
|
const requestOptions = {
|
|
76
76
|
method: "POST",
|
|
77
77
|
credentials: "include",
|
|
@@ -158,6 +158,7 @@ function UserProvider({
|
|
|
158
158
|
try {
|
|
159
159
|
const api = new SparkStudioAuthenticationSDK(authenticationUrl);
|
|
160
160
|
await api.auth.Logout?.();
|
|
161
|
+
localStorage.setItem("auth_token", "");
|
|
161
162
|
onLogoutSuccess?.();
|
|
162
163
|
} catch (err) {
|
|
163
164
|
console.warn(
|
|
@@ -208,6 +209,7 @@ function LoginButton({ onLogin, onLoginFailed }) {
|
|
|
208
209
|
Token: tokenResponse.access_token
|
|
209
210
|
});
|
|
210
211
|
const user = authentication?.User ?? null;
|
|
212
|
+
localStorage.setItem("auth_token", authentication?.Token ?? "");
|
|
211
213
|
const accountsApi = new import_accounts_sdk.SparkStudioAccountsSDK(accountsUrl);
|
|
212
214
|
const dbUser = await accountsApi.users.SyncUser();
|
|
213
215
|
setUser(dbUser);
|
package/dist/index.d.cts
CHANGED
|
@@ -46,10 +46,12 @@ declare function AuthenticatorProvider({ googleClientId, authenticationUrl, acco
|
|
|
46
46
|
* Represents an Auto-generated model for AuthResponse.
|
|
47
47
|
*/
|
|
48
48
|
interface IAuthResponse {
|
|
49
|
+
Token?: string;
|
|
49
50
|
User: UserDTO;
|
|
50
51
|
}
|
|
51
52
|
type AuthResponseInit = Partial<IAuthResponse> & Pick<IAuthResponse, "User">;
|
|
52
53
|
declare class AuthResponse implements IAuthResponse {
|
|
54
|
+
Token?: string;
|
|
53
55
|
User: UserDTO;
|
|
54
56
|
constructor(init: AuthResponseInit);
|
|
55
57
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -46,10 +46,12 @@ declare function AuthenticatorProvider({ googleClientId, authenticationUrl, acco
|
|
|
46
46
|
* Represents an Auto-generated model for AuthResponse.
|
|
47
47
|
*/
|
|
48
48
|
interface IAuthResponse {
|
|
49
|
+
Token?: string;
|
|
49
50
|
User: UserDTO;
|
|
50
51
|
}
|
|
51
52
|
type AuthResponseInit = Partial<IAuthResponse> & Pick<IAuthResponse, "User">;
|
|
52
53
|
declare class AuthResponse implements IAuthResponse {
|
|
54
|
+
Token?: string;
|
|
53
55
|
User: UserDTO;
|
|
54
56
|
constructor(init: AuthResponseInit);
|
|
55
57
|
}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var Auth = class {
|
|
|
14
14
|
}
|
|
15
15
|
async Logout() {
|
|
16
16
|
const url = `${this.baseUrl}/api/Auth/Logout`;
|
|
17
|
-
const token =
|
|
17
|
+
const token = localStorage.getItem("auth_token");
|
|
18
18
|
const requestOptions = {
|
|
19
19
|
method: "GET",
|
|
20
20
|
credentials: "include",
|
|
@@ -29,7 +29,7 @@ var Auth = class {
|
|
|
29
29
|
}
|
|
30
30
|
async GetCurrentUser() {
|
|
31
31
|
const url = `${this.baseUrl}/api/Auth/GetCurrentUser`;
|
|
32
|
-
const token =
|
|
32
|
+
const token = localStorage.getItem("auth_token");
|
|
33
33
|
const requestOptions = {
|
|
34
34
|
method: "GET",
|
|
35
35
|
credentials: "include",
|
|
@@ -44,7 +44,7 @@ var Auth = class {
|
|
|
44
44
|
}
|
|
45
45
|
async SignIn(tokenRequest) {
|
|
46
46
|
const url = `${this.baseUrl}/api/Auth/SignIn`;
|
|
47
|
-
const token =
|
|
47
|
+
const token = localStorage.getItem("auth_token");
|
|
48
48
|
const requestOptions = {
|
|
49
49
|
method: "POST",
|
|
50
50
|
credentials: "include",
|
|
@@ -131,6 +131,7 @@ function UserProvider({
|
|
|
131
131
|
try {
|
|
132
132
|
const api = new SparkStudioAuthenticationSDK(authenticationUrl);
|
|
133
133
|
await api.auth.Logout?.();
|
|
134
|
+
localStorage.setItem("auth_token", "");
|
|
134
135
|
onLogoutSuccess?.();
|
|
135
136
|
} catch (err) {
|
|
136
137
|
console.warn(
|
|
@@ -181,6 +182,7 @@ function LoginButton({ onLogin, onLoginFailed }) {
|
|
|
181
182
|
Token: tokenResponse.access_token
|
|
182
183
|
});
|
|
183
184
|
const user = authentication?.User ?? null;
|
|
185
|
+
localStorage.setItem("auth_token", authentication?.Token ?? "");
|
|
184
186
|
const accountsApi = new SparkStudioAccountsSDK(accountsUrl);
|
|
185
187
|
const dbUser = await accountsApi.users.SyncUser();
|
|
186
188
|
setUser(dbUser);
|