Bladeren bron

:pencil2: Removed old commented out code, added TODO for hasher, etc.

tags/0.0.4
tomit4 2 jaren geleden
bovenliggende
commit
0f7f8a43e6
1 gewijzigde bestanden met toevoegingen van 4 en 23 verwijderingen
  1. 4
    23
      backend/lib/services/user.js

+ 4
- 23
backend/lib/services/user.js Bestand weergeven

8
 
8
 
9
 // Configuration for Brevo
9
 // Configuration for Brevo
10
 const SibApiV3Sdk = require('sib-api-v3-sdk')
10
 const SibApiV3Sdk = require('sib-api-v3-sdk')
11
-const { access, accessSync } = require('fs')
12
 const defaultClient = SibApiV3Sdk.ApiClient.instance
11
 const defaultClient = SibApiV3Sdk.ApiClient.instance
13
 const apiKey = defaultClient.authentications['api-key']
12
 const apiKey = defaultClient.authentications['api-key']
14
 apiKey.apiKey = process.env.BREVO_KEY
13
 apiKey.apiKey = process.env.BREVO_KEY
15
-
16
 const apiInstance = new SibApiV3Sdk.TransactionalEmailsApi()
14
 const apiInstance = new SibApiV3Sdk.TransactionalEmailsApi()
17
 
15
 
16
+// TODO: Consider implementing, nice use of SecurePassword,
17
+// but currently not used anywhere...
18
 const hasher = async (pwd, steak) => {
18
 const hasher = async (pwd, steak) => {
19
     const hash = await pwd.hash(steak)
19
     const hash = await pwd.hash(steak)
20
     const result = await pwd.verify(steak, hash)
20
     const result = await pwd.verify(steak, hash)
57
         const pwd = new SecurePassword()
57
         const pwd = new SecurePassword()
58
         // TODO: Invalidate this application state somehow after a
58
         // TODO: Invalidate this application state somehow after a
59
         // certain time period has passed
59
         // certain time period has passed
60
-        this.activeSessions = {
61
-            // abc123456: '123456689',
62
-            // eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...hashedSessionToken: {
63
-            // email: rawEmailString,
64
-            // name: 'Joe Doe',
65
-            // seeking: 'candidate'
66
-            // sessionToken: rawSessionToken, // use for expires instead of expires?
67
-            // expires: expirationTime in seconds
68
-            // }
69
-        }
70
-        // Check the hashedCookie which is our hashedSessionToken string
71
-        // validate whether or not the rawAccessToken is still valid, if valid good to go.
72
-        // if NOT valid, then we need to reassign accessToken to a newAccessToken
73
-        // this.activeSessions = {
74
-        // eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...hashedSessionToken: {
75
-        // accessToken: 'as;dflkja;;dlfkja;sldkf... rawAccessToken'
76
-        // }
77
-        // }
60
+        this.activeSessions = {}
78
 
61
 
79
         this.pwd = {
62
         this.pwd = {
80
             hash: Util.promisify(pwd.hash.bind(pwd)),
63
             hash: Util.promisify(pwd.hash.bind(pwd)),
334
      * @ returns {Object}
317
      * @ returns {Object}
335
      */
318
      */
336
     async emailSent(userCredentials) {
319
     async emailSent(userCredentials) {
337
-        const hashedSessionToken = await this.hashToken(
338
-            userCredentials.sessionToken,
339
-        )
320
+        const hashedSessionToken = this.hashToken(userCredentials.sessionToken)
340
         if (Object.keys(this.activeSessions).includes(hashedSessionToken)) {
321
         if (Object.keys(this.activeSessions).includes(hashedSessionToken)) {
341
             return new Error('session already in cache!!')
322
             return new Error('session already in cache!!')
342
         }
323
         }

Laden…
Annuleren
Opslaan