-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use sub from JWT #134
Use sub from JWT #134
Conversation
2c54e01
to
253a2b9
Compare
app/src/services/user.ts
Outdated
@@ -151,11 +151,11 @@ const service = { | |||
* @param {string} [defaultValue=undefined] An optional default return value | |||
* @returns {string} The current userId if applicable, or `defaultValue` | |||
*/ | |||
getCurrentUserId: async (identityId: string, defaultValue: string | undefined = undefined) => { | |||
getCurrentUserId: async (sub: string | undefined, defaultValue: string | undefined = undefined) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type: There should never be a situation where a subject is undefined in a JWT.
JSDoc: Don't forget to update the JSDoc param names too.
app/src/controllers/enquiry.ts
Outdated
@@ -4,7 +4,7 @@ import { generateCreateStamps, generateUpdateStamps } from '../db/utils/utils'; | |||
import { activityService, enquiryService, noteService, userService } from '../services'; | |||
import { Initiative } from '../utils/enums/application'; | |||
import { ApplicationStatus, IntakeStatus, NoteType, SubmissionType } from '../utils/enums/housing'; | |||
import { getCurrentIdentity, getCurrentTokenUsername } from '../utils/utils'; | |||
import { getCurrentTokenSub, getCurrentTokenUsername } from '../utils/utils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional Style: It might be possible to rename to getCurrentSubject
and getCurrentUsername
as this information will always be inferred to have come from the JWT token.
JWT now provides the correct sub. Now using that over preffered_username. Update database and models to accuractely reflect this change.
253a2b9
to
8c101f4
Compare
Description
JWT now provides the correct sub. Now using that over
preffered_username
. Update code, and database to accurately reflect this change.Types of changes
New feature (non-breaking change which adds functionality)
Checklist
Further comments