diaseu 3 лет назад
Родитель
Сommit
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,7 +9,7 @@ module.exports = class Auth extends Schwifty.Model {
9 9
         return Joi.object({
10 10
             user_email: Joi.string().required(),
11 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,15 +97,19 @@ module.exports = class UserService extends Schmervice.Service {
97 97
         }
98 98
         // const todayTest = new Date.now()
99 99
         console.log("password passed to .signup()", password)
100
-        const steak = process.env.PEPPER+password
101 100
         console.log("steak", steak)
102 101
         console.log("user_email", userInfo.user_email)
103 102
 
104 103
         const { email } = await Auth.query(txn).insert({
105 104
             user_email: userInfo.user_email,
106 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 113
         return userInfo.user_email
110 114
         console.log("signup return finished")
111 115
         // Library: Secure-Password
@@ -222,7 +226,9 @@ module.exports = class UserService extends Schmervice.Service {
222 226
             .where({ email })
223 227
             .patch({
224 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 233
         console.log("changed pw return", email)
228 234
         console.log("token created in changePassword", this.pwd.hash(Buffer.from(password)))

Загрузка…
Отмена
Сохранить