@joystick.js/node-canary 0.0.0-canary.358 → 0.0.0-canary.359

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.
@@ -1 +1 @@
1
- import i from"bcrypt";import o from"../databases/queries/accounts.js";import c from"./generate_account_session.js";import d from"../api/get_output.js";import n from"../../lib/types.js";const u=(s=null,e=null)=>o("add_session",{user_id:s,session:e}),_=(s=null)=>o("get_existing_session",{user_id:s}),l=(s=null)=>o("delete_old_sessions",{user_id:s}),p=(s=null,e=null)=>i.compareSync(s,e),m=async(s={})=>{const e=await o("user",{email_address:s.email_address||s.emailAddress,username:s.username});if(!e)throw new Error(`A user with the ${s.email_address||s.emailAddress?"email address":"username"} ${s.email_address||s.emailAddress||s.username} could not be found.`);if(!p(s.password,e.password))throw new Error("Incorrect password.");const t=e?._id||e?.user_id;await l(t);let r=await _(t);console.log({user:e,session:r}),r||(r=c(),await u(t,r));const{password:f,sessions:y,...a}=e;return(n.is_function(process.joystick?.app_options?.accounts?.events?.onLogin)||n.is_function(process.joystick?.app_options?.accounts?.events?.on_login))&&(process.joystick?.app_options?.accounts?.events?.onLogin||process.joystick?.app_options?.accounts?.events?.on_login)({...r,user:e}),{...r,user:d({...a},s?.output)}};var g=m;export{g as default};
1
+ import i from"bcrypt";import o from"../databases/queries/accounts.js";import c from"./generate_account_session.js";import d from"../api/get_output.js";import n from"../../lib/types.js";const u=(s=null,e=null)=>o("add_session",{user_id:s,session:e}),_=(s=null)=>o("get_existing_session",{user_id:s}),l=(s=null)=>o("delete_old_sessions",{user_id:s}),p=(s=null,e=null)=>i.compareSync(s,e),m=async(s={})=>{const e=await o("user",{email_address:s.email_address||s.emailAddress,username:s.username});if(console.log({user:e}),!e)throw new Error(`A user with the ${s.email_address||s.emailAddress?"email address":"username"} ${s.email_address||s.emailAddress||s.username} could not be found.`);if(!p(s.password,e.password))throw new Error("Incorrect password.");const t=e?._id||e?.user_id;await l(t);let r=await _(t);console.log({user:e,session:r}),r||(r=c(),await u(t,r));const{password:f,sessions:y,...a}=e;return(n.is_function(process.joystick?.app_options?.accounts?.events?.onLogin)||n.is_function(process.joystick?.app_options?.accounts?.events?.on_login))&&(process.joystick?.app_options?.accounts?.events?.onLogin||process.joystick?.app_options?.accounts?.events?.on_login)({...r,user:e}),{...r,user:d({...a},s?.output)}};var A=m;export{A as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.358",
4
+ "version": "0.0.0-canary.359",
5
5
  "description": "The Node.js framework for Joystick.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {
@@ -28,6 +28,10 @@ const login = async (login_options = {}) => {
28
28
  username: login_options.username,
29
29
  });
30
30
 
31
+ console.log({
32
+ user,
33
+ })
34
+
31
35
  if (!user) {
32
36
  throw new Error(
33
37
  `A user with the ${