Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/actions/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ describe('Actions', () => {
object: 'user',
id: '01JATCHZVEC5EPANDPEZVM68Y9',
email: 'jane@foocorp.com',
name: 'Jane Doe',
firstName: 'Jane',
lastName: 'Doe',
emailVerified: true,
Expand Down Expand Up @@ -178,6 +179,7 @@ describe('Actions', () => {
userData: {
object: 'user_data',
email: 'jane@foocorp.com',
name: 'Jane Doe',
firstName: 'Jane',
lastName: 'Doe',
},
Expand Down
1 change: 1 addition & 0 deletions src/actions/fixtures/authentication-action-context.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"object": "user",
"id": "01JATCHZVEC5EPANDPEZVM68Y9",
"email": "jane@foocorp.com",
"name": "Jane Doe",
"first_name": "Jane",
"last_name": "Doe",
"email_verified": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"user_data": {
"object": "user_data",
"email": "jane@foocorp.com",
"name": "Jane Doe",
"first_name": "Jane",
"last_name": "Doe"
},
Expand Down
2 changes: 2 additions & 0 deletions src/actions/interfaces/action.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface AuthenticationActionContext {
export interface UserData {
object: 'user_data';
email: string;
name: string | null;
firstName: string;
lastName: string;
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Expand Down Expand Up @@ -59,6 +60,7 @@ interface AuthenticationActionPayload {
export interface UserDataPayload {
object: 'user_data';
email: string;
name: string | null;
first_name: string;
last_name: string;
}
Expand Down
1 change: 1 addition & 0 deletions src/actions/serializers/action.serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const deserializeUserData = (userData: UserDataPayload): UserData => {
return {
object: userData.object,
email: userData.email,
name: userData.name ?? null,
firstName: userData.first_name,
lastName: userData.last_name,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"user": {
"object": "user",
"id": "user_01E4ZCR3C56J083X43JQXF3JK5",
"name": "Marcelina Davis",
"first_name": "Marcelina",
"last_name": "Davis",
"profile_picture_url": "https://workoscdn.com/images/v1/123abc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"user": {
"object": "user",
"id": "user_01E4ZCR3C56J083X43JQXF3JK5",
"name": "Marcelina Davis",
"first_name": "Marcelina",
"last_name": "Davis",
"profile_picture_url": "https://workoscdn.com/images/v1/123abc",
Expand Down
2 changes: 2 additions & 0 deletions src/sso/__snapshots__/sso.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ exports[`SSO SSO getProfileAndToken with all information provided sends a reques
"id": "prof_123",
"idpId": "123",
"lastName": "bar",
"name": "foo bar",
"organizationId": "org_123",
"rawAttributes": {
"email": "foo@test.com",
Expand Down Expand Up @@ -68,6 +69,7 @@ exports[`SSO SSO getProfileAndToken without a groups attribute sends a request t
"id": "prof_123",
"idpId": "123",
"lastName": "bar",
"name": "foo bar",
"organizationId": "org_123",
"rawAttributes": {
"email": "foo@test.com",
Expand Down
3 changes: 3 additions & 0 deletions src/sso/interfaces/profile.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface Profile<CustomAttributesType extends UnknownRecord> {
connectionType: ConnectionType;
/** The user's email address. */
email: string;
/** The user's full name. */
name?: string;
/** The user's first name. */
firstName?: string;
/** The user's last name. */
Expand All @@ -38,6 +40,7 @@ export interface ProfileResponse<CustomAttributesType extends UnknownRecord> {
connection_id: string;
connection_type: ConnectionType;
email: string;
name?: string;
first_name?: string;
last_name?: string;
role?: RoleResponse;
Expand Down
1 change: 1 addition & 0 deletions src/sso/serializers/profile.serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const deserializeProfile = <CustomAttributesType extends UnknownRecord>(
connectionId: profile.connection_id,
connectionType: profile.connection_type,
email: profile.email,
...(profile.name !== undefined && { name: profile.name }),
...(profile.first_name !== undefined && { firstName: profile.first_name }),
...(profile.last_name !== undefined && { lastName: profile.last_name }),
...(profile.role !== undefined && { role: profile.role }),
Expand Down
7 changes: 7 additions & 0 deletions src/sso/sso.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ describe('SSO', () => {
connection_id: 'conn_123',
connection_type: 'OktaSAML',
email: 'foo@test.com',
name: 'foo bar',
first_name: 'foo',
last_name: 'bar',
role: {
Expand Down Expand Up @@ -398,6 +399,7 @@ describe('SSO', () => {
connection_id: 'conn_123',
connection_type: 'OktaSAML',
email: 'foo@test.com',
name: 'foo bar',
first_name: 'foo',
last_name: 'bar',
role: {
Expand Down Expand Up @@ -451,6 +453,7 @@ describe('SSO', () => {
connection_id: 'conn_123',
connection_type: 'OktaSAML',
email: 'foo@test.com',
name: 'foo bar',
first_name: 'foo',
last_name: 'bar',
role: {
Expand Down Expand Up @@ -504,6 +507,7 @@ describe('SSO', () => {
connection_id: 'conn_123',
connection_type: 'OktaSAML',
email: 'foo@test.com',
name: 'foo bar',
first_name: 'foo',
last_name: 'bar',
role: {
Expand Down Expand Up @@ -544,6 +548,7 @@ describe('SSO', () => {
connection_id: 'conn_123',
connection_type: 'OktaSAML',
email: 'foo@test.com',
name: 'foo bar',
first_name: 'foo',
last_name: 'bar',
role: { slug: 'admin' },
Expand Down Expand Up @@ -592,6 +597,7 @@ describe('SSO', () => {
connection_id: 'conn_123',
connection_type: 'OktaSAML',
email: 'foo@test.com',
name: 'foo bar',
first_name: 'foo',
last_name: 'bar',
role: { slug: 'admin' },
Expand Down Expand Up @@ -662,6 +668,7 @@ describe('SSO', () => {
connection_id: 'conn_123',
connection_type: 'OktaSAML',
email: 'foo@test.com',
name: 'foo bar',
first_name: 'foo',
last_name: 'bar',
role: {
Expand Down
1 change: 1 addition & 0 deletions src/user-management/fixtures/list-users.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"object": "user",
"id": "user_01H5JQDV7R7ATEYZDEG0W5PRYS",
"email": "test01@example.com",
"name": "Test 01 User",
"first_name": "Test 01",
"last_name": "User",
"created_at": "2023-07-18T02:07:19.911Z",
Expand Down
1 change: 1 addition & 0 deletions src/user-management/fixtures/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"object": "user",
"id": "user_01H5JQDV7R7ATEYZDEG0W5PRYS",
"email": "test01@example.com",
"name": "Test 01 User",
"first_name": "Test 01",
"last_name": "User",
"created_at": "2023-07-18T02:07:19.911Z",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface CreateUserOptions {
password?: string;
passwordHash?: string;
passwordHashType?: PasswordHashType;
name?: string;
firstName?: string;
lastName?: string;
emailVerified?: boolean;
Expand All @@ -17,6 +18,7 @@ export interface SerializedCreateUserOptions {
password?: string;
password_hash?: string;
password_hash_type?: PasswordHashType;
name?: string;
first_name?: string;
last_name?: string;
email_verified?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PasswordHashType } from './password-hash-type.interface';
export interface UpdateUserOptions {
userId: string;
email?: string;
name?: string;
firstName?: string;
lastName?: string;
emailVerified?: boolean;
Expand All @@ -16,6 +17,7 @@ export interface UpdateUserOptions {

export interface SerializedUpdateUserOptions {
email?: string;
name?: string;
first_name?: string;
last_name?: string;
email_verified?: boolean;
Expand Down
3 changes: 3 additions & 0 deletions src/user-management/interfaces/user.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export interface User {
emailVerified: boolean;
/** A URL reference to an image representing the user. */
profilePictureUrl: string | null;
/** The full name of the user. */
name: string | null;
/** The first name of the user. */
firstName: string | null;
/** The last name of the user. */
Expand All @@ -34,6 +36,7 @@ export interface UserResponse {
email: string;
email_verified: boolean;
profile_picture_url: string | null;
name: string | null;
first_name: string | null;
last_name: string | null;
last_sign_in_at: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const serializeCreateUserOptions = (
password: options.password,
password_hash: options.passwordHash,
password_hash_type: options.passwordHashType,
name: options.name,
first_name: options.firstName,
last_name: options.lastName,
email_verified: options.emailVerified,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const serializeUpdateUserOptions = (
): SerializedUpdateUserOptions => ({
email: options.email,
email_verified: options.emailVerified,
name: options.name,
first_name: options.firstName,
last_name: options.lastName,
password: options.password,
Expand Down
1 change: 1 addition & 0 deletions src/user-management/serializers/user.serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const deserializeUser = (user: UserResponse): User => ({
id: user.id,
email: user.email,
emailVerified: user.email_verified,
name: user.name ?? null,
firstName: user.first_name,
profilePictureUrl: user.profile_picture_url,
lastName: user.last_name,
Expand Down
4 changes: 4 additions & 0 deletions src/user-management/user-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('UserManagement', () => {
id: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
email: 'test01@example.com',
profilePictureUrl: 'https://example.com/profile_picture.jpg',
name: 'Test 01 User',
firstName: 'Test 01',
lastName: 'User',
emailVerified: true,
Expand All @@ -81,6 +82,7 @@ describe('UserManagement', () => {
id: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
email: 'test01@example.com',
profilePictureUrl: 'https://example.com/profile_picture.jpg',
name: 'Test 01 User',
firstName: 'Test 01',
lastName: 'User',
emailVerified: true,
Expand Down Expand Up @@ -145,6 +147,7 @@ describe('UserManagement', () => {
expect(user).toMatchObject({
object: 'user',
email: 'test01@example.com',
name: 'Test 01 User',
firstName: 'Test 01',
lastName: 'User',
emailVerified: true,
Expand Down Expand Up @@ -1452,6 +1455,7 @@ describe('UserManagement', () => {
createdAt: '2023-07-18T02:07:19.911Z',
email: 'test01@example.com',
emailVerified: true,
name: 'Test 01 User',
firstName: 'Test 01',
id: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
lastName: 'User',
Expand Down