浏览代码

:pencil2: Fixed semantic issues and addressed edge null case

tags/0.0.4
tomit4 2 年前
父节点
当前提交
19c92e2070

+ 1
- 1
backend/lib/routes/user/validate-session.js 查看文件

33
                 const user = await userService.findByUserEmail(
33
                 const user = await userService.findByUserEmail(
34
                     validatedSessionToken.email,
34
                     validatedSessionToken.email,
35
                 )
35
                 )
36
-                const type = user.is_poster == 1 ? 'poster' : 'seeker'
36
+                const type = user.is_poster === 1 ? 'poster' : 'seeker'
37
                 const profiles = await profileService.getCompleteProfilesFor(
37
                 const profiles = await profileService.getCompleteProfilesFor(
38
                     user.user_id,
38
                     user.user_id,
39
                     type,
39
                     type,

+ 1
- 1
backend/lib/services/profile/index.js 查看文件

45
         /** Grab every Profile associated with this id */
45
         /** Grab every Profile associated with this id */
46
         const allProfiles = await Profile.query().where('user_id', userId)
46
         const allProfiles = await Profile.query().where('user_id', userId)
47
         /** Copy a list of the just the Profiles */
47
         /** Copy a list of the just the Profiles */
48
-        return typeof allProfiles === 'object'
48
+        return typeof allProfiles === 'object' && allProfiles !== null
49
             ? [...new Set(allProfiles.map(profile => profile.profile_id))]
49
             ? [...new Set(allProfiles.map(profile => profile.profile_id))]
50
             : [allProfiles]
50
             : [allProfiles]
51
     }
51
     }

+ 1
- 1
backend/tests/user-create-profile.spec.js 查看文件

38
     payload: JSON.stringify(payload),
38
     payload: JSON.stringify(payload),
39
 }
39
 }
40
 
40
 
41
-test(`path /${params.user_id}/profile should return new profile info`, async t => {
41
+test('path /<user_id>/profile should return new profile info', async t => {
42
     /**
42
     /**
43
      * Create a new server and register services,
43
      * Create a new server and register services,
44
      * models and routes for testing
44
      * models and routes for testing

+ 1
- 1
backend/tests/user-verify-session.spec.js 查看文件

36
     url: `/verify/${params.hashedSessionToken}`,
36
     url: `/verify/${params.hashedSessionToken}`,
37
 }
37
 }
38
 
38
 
39
-test(`path /verify/${params.hashedSessionToken} should return OK on GET`, async t => {
39
+test('path /verify/<hashedSessionToken> should return OK on GET', async t => {
40
     /**
40
     /**
41
      * Create a new server and register services,
41
      * Create a new server and register services,
42
      * models and routes for testing
42
      * models and routes for testing

正在加载...
取消
保存