Skip to content

Commit

Permalink
chore: add username on register + beautify edit profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
kasir-barati committed May 17, 2024
1 parent ddfbe14 commit c10ee88
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 22 deletions.
17 changes: 3 additions & 14 deletions apps/backend/openApi.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,6 @@
}
}
},
"401": {
"description": "Could not validate and verify the provided JWT token",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UnauthorizedException"
}
}
}
},
"500": {
"description": "Internal server error.",
"content": {
Expand All @@ -304,8 +294,7 @@
}
}
},
"tags": ["Auth"],
"security": [{ "bearer": [] }]
"tags": ["Auth"]
}
},
"/auth/refresh": {
Expand Down Expand Up @@ -761,12 +750,12 @@
"createdAt": {
"type": "string",
"description": "Post created at",
"example": "Fri May 10 2024 14:19:53 GMT+0200 (Central European Summer Time)"
"example": "Fri May 17 2024 16:33:54 GMT+0200 (Central European Summer Time)"
},
"updatedAt": {
"type": "string",
"description": "Post updated at",
"example": "Fri May 10 2024 14:19:53 GMT+0200 (Central European Summer Time)"
"example": "Fri May 17 2024 16:33:54 GMT+0200 (Central European Summer Time)"
}
},
"required": [
Expand Down
6 changes: 4 additions & 2 deletions apps/backend/src/modules/post/dto/post.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ export class PostDto implements Post {

@ApiProperty({
description: 'Post created at',
example: new Date().toString(),
example:
'Fri May 17 2024 16:33:54 GMT+0200 (Central European Summer Time)',
})
createdAt: string;

@ApiProperty({
description: 'Post updated at',
example: new Date().toString(),
example:
'Fri May 17 2024 16:33:54 GMT+0200 (Central European Summer Time)',
})
updatedAt: string;
}
4 changes: 2 additions & 2 deletions apps/frontend/src/app/profile/[username]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const VisuallyHiddenInput = styled('input')({
});
const EditProfileGrid2Box = styled(Grid2)({
width: '100%',
backgroundColor: '#455572',
backgroundColor: '#45557211',
borderRadius: '8px',
});
const EditProfileTitle = ({
Expand Down Expand Up @@ -63,7 +63,7 @@ export default function EditProfile({
};

return (
<Container>
<Container sx={{ paddingY: 3 }}>
<Box
display="flex"
alignItems="center"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function AccountButton() {
const name = userInfo?.family_name ?? 'Family';
const email = userInfo?.email ?? '[email protected]';
// TODO: https://github.com/FusionAuth/fusionauth-javascript-sdk/issues/94
const username = 'userInfo?.preferred_username';
const username = userInfo?.preferred_username;
// TODO: fetch countdown data in quests collection!
const handleComplete = () => {
console.log('');
Expand Down Expand Up @@ -96,6 +96,7 @@ export function AccountButton() {
component={Link}
href={`/profile/${username}/edit`}
underline="none"
onClick={closeModal}
>
Edit
</MuiLink>
Expand Down
6 changes: 3 additions & 3 deletions deployment/fusionauth/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ data "httpclient_request" "set-default-tenant-theme" {
resource "fusionauth_user" "you-say-admin-user" {
tenant_id = fusionauth_tenant.you-say-tenant.id
email = "[email protected]"
username = "admin@you-say.com"
username = "admin"
first_name = "Admin"
last_name = "Admin"
password = "adminadmin"
Expand All @@ -275,7 +275,7 @@ resource "fusionauth_registration" "you-say-admin-registration" {
resource "fusionauth_user" "you-say-temp-user" {
tenant_id = fusionauth_tenant.you-say-tenant.id
email = "[email protected]"
username = "[email protected]"
username = "souma_kazuya"
first_name = "Souma"
last_name = "Kazuya"
password = "souma.kazuya"
Expand Down Expand Up @@ -305,7 +305,7 @@ data "httpclient_request" "create-super-admin-user" {
"skipVerification" : true,
"registration" : {
"roles" : ["admin"],
"username" : "admin@admin.com"
"username" : "admin"
"applicationId" : "${local.fusionauth_default_application_id}",
}
"user" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ describe('FusionAuthClientHelper', () => {
firstName: registerArgs.firstName,
password: registerArgs.password,
fullName: `${registerArgs.firstName} ${registerArgs.lastName}`,
username: Sinon.match.string,
data: {},
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export class FusionAuthClientHelper implements OnModuleInit {
applicationId,
}: Register): Promise<string> | never {
const memberships = this.getMemberships(groups);
const username = email
.substring(0, email.indexOf('@'))
.replace(/[!#$%&'*+-/=?^_`{|}~]/g, '_')
.trim();

try {
// Passing an empty string as userId signifies that FusionAuth should create it automatically.
Expand All @@ -158,6 +162,7 @@ export class FusionAuthClientHelper implements OnModuleInit {
memberships,
...(password ? { password } : {}),
fullName: `${firstName} ${lastName}`,
username,
data: {
// Here we can save meta data, or settings and other info
},
Expand Down

0 comments on commit c10ee88

Please sign in to comment.