@quatrain/auth-supabase 1.0.0-beta2 → 1.0.0-beta4
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.
|
@@ -7,7 +7,7 @@ export declare class SupabaseAuthAdapter extends AbstractAuthAdapter {
|
|
|
7
7
|
* @param user
|
|
8
8
|
* @returns user unique id
|
|
9
9
|
*/
|
|
10
|
-
register(user: User): Promise<
|
|
10
|
+
register(user: User): Promise<any>;
|
|
11
11
|
getAuthToken(bearer: string): Promise<any>;
|
|
12
12
|
signup(login: string, password: string): Promise<void>;
|
|
13
13
|
signout(user: User): Promise<any>;
|
|
@@ -27,26 +27,29 @@ class SupabaseAuthAdapter extends core_1.AbstractAuthAdapter {
|
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
28
|
try {
|
|
29
29
|
const { name: displayName, email, phone: phoneNumber, password, disabled = false, } = user._;
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
core_1.Core.log(`[SAA] Adding user '${displayName}'`);
|
|
31
|
+
const { data, error } = yield this._client.auth.signUp({
|
|
32
32
|
email,
|
|
33
|
-
phoneNumber,
|
|
34
33
|
password,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return; // userRecord.uid
|
|
34
|
+
});
|
|
35
|
+
if (error) {
|
|
36
|
+
throw new Error(error);
|
|
37
|
+
}
|
|
38
|
+
return data.user;
|
|
41
39
|
}
|
|
42
40
|
catch (err) {
|
|
41
|
+
console.log(err);
|
|
43
42
|
throw new core_1.AuthenticationError(err.message);
|
|
44
43
|
}
|
|
45
44
|
});
|
|
46
45
|
}
|
|
47
46
|
getAuthToken(bearer) {
|
|
48
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
|
|
48
|
+
const token = yield this._client.auth.getUser(bearer);
|
|
49
|
+
if (token.data && token.data.user) {
|
|
50
|
+
return token.data.user;
|
|
51
|
+
}
|
|
52
|
+
throw new Error('Unable to retrieve auth token from Supabase');
|
|
50
53
|
});
|
|
51
54
|
}
|
|
52
55
|
signup(login, password) {
|