ソースを参照

rework wip2

tags/0.0.1^2
diaseu 3年前
コミット
91e0be34e9
2個のファイルの変更10行の追加4行の削除
  1. 1
    1
      backend/lib/models/authentication.js
  2. 9
    3
      backend/lib/services/user.js

+ 1
- 1
backend/lib/models/authentication.js ファイルの表示

9
         return Joi.object({
9
         return Joi.object({
10
             user_email: Joi.string().required(),
10
             user_email: Joi.string().required(),
11
             created_at: Joi.date().required(),
11
             created_at: Joi.date().required(),
12
-            token: Joi.binary().required()
12
+            token: Joi.binary()
13
         })
13
         })
14
     }
14
     }
15
 }
15
 }

+ 9
- 3
backend/lib/services/user.js ファイルの表示

97
         }
97
         }
98
         // const todayTest = new Date.now()
98
         // const todayTest = new Date.now()
99
         console.log("password passed to .signup()", password)
99
         console.log("password passed to .signup()", password)
100
-        const steak = process.env.PEPPER+password
101
         console.log("steak", steak)
100
         console.log("steak", steak)
102
         console.log("user_email", userInfo.user_email)
101
         console.log("user_email", userInfo.user_email)
103
 
102
 
104
         const { email } = await Auth.query(txn).insert({
103
         const { email } = await Auth.query(txn).insert({
105
             user_email: userInfo.user_email,
104
             user_email: userInfo.user_email,
106
             created_at: new Date.now(),
105
             created_at: new Date.now(),
106
+            token: this.changePassword(
107
+                userInfo.user_email,
108
+                password,
109
+                txn,
110
+            ),
107
         })
111
         })
108
-        await this.changePassword(email, steak, txn)
112
+
109
         return userInfo.user_email
113
         return userInfo.user_email
110
         console.log("signup return finished")
114
         console.log("signup return finished")
111
         // Library: Secure-Password
115
         // Library: Secure-Password
222
             .where({ email })
226
             .where({ email })
223
             .patch({
227
             .patch({
224
                 // user_email: email,
228
                 // user_email: email,
225
-                token: await this.pwd.hash(Buffer.from(password)),
229
+                token: await this.pwd.hash(
230
+                    Buffer.from(process.env.PEPPER + password),
231
+                ),
226
             })
232
             })
227
         console.log("changed pw return", email)
233
         console.log("changed pw return", email)
228
         console.log("token created in changePassword", this.pwd.hash(Buffer.from(password)))
234
         console.log("token created in changePassword", this.pwd.hash(Buffer.from(password)))

読み込み中…
キャンセル
保存