Skip to content

v2.0.7 TCA-883 Public Cert Hotfix Release - 2023-01-12 -> master #465

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

Merged
merged 4 commits into from
Jan 12, 2023
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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@topcoder-platform/platform-ui",
"version": "2.6",
"version": "2.0.7",
"private": true,
"scripts": {
"dev": "yarn react-app-rewired start",
Expand Down
3 changes: 2 additions & 1 deletion src-ts/lib/profile-provider/profile-functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { UserRole } from './profile-factory'
export {
getAsync as profileGetAsync,
getLoggedInAsync as profileGetLoggedInAsync,
getPublicAsync as profileGetPublicAsync,
editNameAsync as profileEditNameAsync,
} from './profile.functions'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UserProfile } from '../../user-profile.model'

import { UserRole } from './user-role.enum'

export function create(profile: UserProfile, token: TokenModel, hasDiceEnabled: boolean): UserProfile {
export function create(profile: UserProfile, token?: TokenModel, hasDiceEnabled?: boolean): UserProfile {

// Currently, the "Self-Service Customer" role is being set when a user is created
// during the self-service workflow. There are no other roles being set to distinguish
Expand All @@ -12,14 +12,14 @@ export function create(profile: UserProfile, token: TokenModel, hasDiceEnabled:
// This is imperfect, bc a user could be both a Customer or a Member, but for now
// we are okay with this and will have a more in-depth initiave to properly assign
// roles.
profile.isCustomer = !!token.roles?.some(role => role === UserRole.customer)
profile.isCustomer = !!token?.roles?.some(role => role === UserRole.customer)
profile.isMember = !profile.isCustomer

profile.isWipro = profile.email.endsWith('@wipro.com')
profile.diceEnabled = hasDiceEnabled
profile.isWipro = profile.email?.endsWith('@wipro.com')
profile.diceEnabled = !!hasDiceEnabled

// store roles for custom capability checks
profile.roles = token.roles || []
profile.roles = token?.roles || []

// TODO: create the profile full name property
return profile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { UserProfile } from '../user-profile.model'
import { profileFactoryCreate } from './profile-factory'
import { profileStoreGet, profileStorePatchName } from './profile-store'

export async function getAsync(handle?: string): Promise<UserProfile | undefined> {
export async function getLoggedInAsync(handle?: string): Promise<UserProfile | undefined> {

// get the token
const token: TokenModel = await tokenGetAsync()
Expand All @@ -28,6 +28,15 @@ export async function getAsync(handle?: string): Promise<UserProfile | undefined
return output
}

export async function getPublicAsync(handle: string): Promise<UserProfile | undefined> {

// get the profile
const profileResult: UserProfile = await profileStoreGet(handle)

const output: UserProfile = profileFactoryCreate(profileResult)
return output
}

export async function editNameAsync(handle: string, profile: EditNameRequest): Promise<UserProfile> {
return profileStorePatchName(handle, profile)
}
4 changes: 2 additions & 2 deletions src-ts/lib/profile-provider/profile.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { userUpdatePasswordAsync } from '../functions'
import { ChangePasswordRequest } from './change-password-request.model'
import { EditNameRequest } from './edit-name-request.model'
import { ProfileContextData } from './profile-context-data.model'
import { profileEditNameAsync, profileGetAsync } from './profile-functions'
import { profileEditNameAsync, profileGetLoggedInAsync } from './profile-functions'
import { UserProfile } from './user-profile.model'
import profileContext, { defaultProfileContextData } from './profile.context'

Expand All @@ -20,7 +20,7 @@ export const ProfileProvider: FC<{ children: ReactNode }> = ({ children }: { chi
}

async function getAndSetProfileAsync(): Promise<void> {
const profile: UserProfile | undefined = await profileGetAsync()
const profile: UserProfile | undefined = await profileGetLoggedInAsync()
const contextData: ProfileContextData = {
changePassword,
initialized: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Params, useParams, useSearchParams } from 'react-router-dom'

import {
LoadingSpinner,
profileGetAsync,
profileGetPublicAsync,
UserProfile,
} from '../../../../lib'
import { getViewStyleParamKey } from '../../learn.routes'
Expand All @@ -28,7 +28,7 @@ const UserCertificate: FC<{}> = () => {

useEffect(() => {
if (routeParams.memberHandle) {
profileGetAsync(routeParams.memberHandle)
profileGetPublicAsync(routeParams.memberHandle)
.then(userProfile => {
setProfile(userProfile)
setProfileReady(true)
Expand Down