sveltekit-auth-example 1.0.6 → 1.0.7

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.0.7
2
+ * Bump dependencies and verify against latest SvelteKit
3
+ * Additional changes for register PostgreSQL function
4
+
1
5
  # 1.0.5
2
6
  * Bump dependencies
3
7
  * [Fix] Flaw in register allowing user to register over top of an existing account
package/db_create.sql CHANGED
@@ -182,15 +182,17 @@ DECLARE
182
182
  input_phone varchar(23) := TRIM((input->>'phone')::varchar);
183
183
  input_password varchar(80) := (input->>'password')::varchar;
184
184
  BEGIN
185
- SELECT json_build_object('id', create_session(users.id), 'user', json_build_object('id', users.id, 'role', users.role, 'email', input_email, 'firstName', users.first_name, 'lastName', users.last_name, 'phone', users.phone)) INTO user_session FROM users WHERE email = input_email;
185
+ PERFORM id FROM users WHERE email = input_email;
186
186
  IF NOT FOUND THEN
187
187
  INSERT INTO users(role, password, email, first_name, last_name, phone)
188
- VALUES('student', crypt(input_password, input_password), input_email, input_first_name, input_last_name, input_phone)
188
+ VALUES('student', crypt(input_password, gen_salt('bf', 8)), input_email, input_first_name, input_last_name, input_phone)
189
189
  RETURNING
190
190
  json_build_object(
191
191
  'sessionId', create_session(users.id),
192
- 'user', json_build_object('id', users.id, 'role', 'student', 'email', input_email, 'firstName', input_first_name, 'lastName', input_last_name, 'phone', input_phone)
192
+ 'user', json_build_object('id', users.id, 'role', 'student', 'email', input_email, 'firstName', input_first_name, 'lastName', input_last_name, 'phone', input_phone, 'optOut', false)
193
193
  ) INTO user_session;
194
+ ELSE -- user is registering account that already exists so set sessionId and user to null so client can let them know
195
+ SELECT authenticate(input) INTO user_session;
194
196
  END IF;
195
197
  END;
196
198
  $BODY$;
@@ -210,7 +212,7 @@ DECLARE
210
212
  input_first_name varchar(20) := TRIM((input->>'firstName')::varchar);
211
213
  input_last_name varchar(20) := TRIM((input->>'lastName')::varchar);
212
214
  BEGIN
213
- PERFORM id FROM users WHERE email = input_email;
215
+ SELECT json_build_object('id', create_session(users.id), 'user', json_build_object('id', users.id, 'role', users.role, 'email', input_email, 'firstName', users.first_name, 'lastName', users.last_name, 'phone', users.phone)) INTO user_session FROM users WHERE email = input_email;
214
216
  IF NOT FOUND THEN
215
217
  INSERT INTO users(role, email, first_name, last_name)
216
218
  VALUES('student', input_email, input_first_name, input_last_name)
@@ -219,8 +221,6 @@ BEGIN
219
221
  'id', create_session(users.id),
220
222
  'user', json_build_object('id', users.id, 'role', 'student', 'email', input_email, 'firstName', input_first_name, 'lastName', input_last_name, 'phone', null)
221
223
  ) INTO user_session;
222
- ELSE
223
- SELECT authenticate(input) INTO user_session;
224
224
  END IF;
225
225
  END;
226
226
  $BODY$;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sveltekit-auth-example",
3
3
  "description": "SvelteKit Authentication Example",
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "private": false,
6
6
  "author": "Nate Stuyvesant",
7
7
  "license": "https://github.com/nstuyvesant/sveltekit-auth-example/blob/master/LICENSE",
@@ -32,14 +32,14 @@
32
32
  "format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
33
33
  },
34
34
  "engines": {
35
- "node": "~16.14.2",
35
+ "node": "~16.15.0",
36
36
  "npm": "^8.8.0"
37
37
  },
38
38
  "type": "module",
39
39
  "dependencies": {
40
40
  "cookie": "^0.5.0",
41
41
  "dotenv": "^16.0.0",
42
- "google-auth-library": "^8.0.1",
42
+ "google-auth-library": "^8.0.2",
43
43
  "jsonwebtoken": "^8.5.1",
44
44
  "pg": "^8.7.3",
45
45
  "pg-native": "^3.0.0"
@@ -49,8 +49,8 @@
49
49
  "@sveltejs/kit": "latest",
50
50
  "@types/jsonwebtoken": "^8.5.8",
51
51
  "@types/pg": "^8.6.5",
52
- "@typescript-eslint/eslint-plugin": "^5.21.0",
53
- "@typescript-eslint/parser": "^5.21.0",
52
+ "@typescript-eslint/eslint-plugin": "^5.22.0",
53
+ "@typescript-eslint/parser": "^5.22.0",
54
54
  "bootstrap": "^5.1.3",
55
55
  "bootstrap-icons": "^1.8.1",
56
56
  "eslint": "^8.14.0",
@@ -59,10 +59,10 @@
59
59
  "prettier": "^2.6.2",
60
60
  "prettier-plugin-svelte": "^2.7.0",
61
61
  "sass": "^1.51.0",
62
- "svelte": "^3.47.0",
62
+ "svelte": "^3.48.0",
63
63
  "svelte-check": "^2.7.0",
64
64
  "svelte-preprocess": "^4.10.6",
65
65
  "tslib": "^2.4.0",
66
- "typescript": "^4.6.3"
66
+ "typescript": "^4.6.4"
67
67
  }
68
68
  }