Skip to content

Commit

Permalink
register bug source of null
Browse files Browse the repository at this point in the history
  • Loading branch information
dayo.ogundipe committed Mar 16, 2024
1 parent 0659606 commit 3c9ea75
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion API/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ public async Task<ActionResult<UserDto>>GetCurrentUser(){

private UserDto CreateUserObject(AppUser user)
{

var photo = user.Photos!=null? user.Photos.FirstOrDefault(x=>x.IsMain)?.Url: "";
return new UserDto
{
DisplayName = user.DisplayName,
Image = user.Photos.FirstOrDefault(x=>x.IsMain)?.Url,
Image = photo,
Token = _tokenSerivce.CreateToken(user),
Username = user.UserName

Expand Down
2 changes: 1 addition & 1 deletion client-app/src/features/errors/ValidationErrors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Props {
export default function ValidationError({ errors }: Props) {
return (
<Message error>
{errors && (
{Array.isArray(errors) && (
<Message.List>
{errors.map((err: string, i) => (
<Message.Item key={i}>{err}</Message.Item>
Expand Down
7 changes: 5 additions & 2 deletions client-app/src/features/users/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as Yup from "yup";
import ValidationError from "../errors/ValidationErrors";

export default observer(function RegisterForm() {
const { userStore } = useStore();
const { userStore, modalStore } = useStore();
return (
<Formik
initialValues={{
Expand All @@ -18,7 +18,10 @@ export default observer(function RegisterForm() {
error: null,
}}
onSubmit={(values, { setErrors }) =>
userStore.register(values).catch((error) => setErrors({ error }))
userStore.register(values).catch((error) => {
modalStore.closeModal();
setErrors({ error });
})
}
validationSchema={Yup.object({
displayName: Yup.string().required(),
Expand Down

0 comments on commit 3c9ea75

Please sign in to comment.