Skip to content

Commit

Permalink
Using strings on error handling instead of imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
sandulat committed Sep 23, 2020
1 parent e63f085 commit 544a4f8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ APP_URL=
DATABASE_URL=

# Mail drivers: SENDGRID, SMTP, PREVIEW
MAIL_DRIVER=PREVIEW
MAIL_DRIVER=
MAIL_HOST=
MAIL_PORT=
MAIL_USER=
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ blitz-log.log
# local env files
.env.local
.env.*.local
.env.production
.env.*.production
.envrc

# Logs
Expand Down
7 changes: 3 additions & 4 deletions app/auth/components/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useRef } from "react"
import { AuthenticationError, Link } from "blitz"
import { Link } from "blitz"
import { TextField } from "app/components/TextField"
import { Form, FORM_ERROR } from "app/components/Form"
import login from "app/auth/mutations/login"
Expand All @@ -10,7 +10,6 @@ import { Logo } from "app/components/Logo"
import { AuthHeading } from "./AuthHeading"
import { AuthWrapper } from "./AuthWrapper"
import { AuthSubheading } from "./AuthSubheading"
import { UnconfirmedEmailError } from "app/errors/unconfirmedEmail"

type LoginFormProps = {
onSuccess?: () => void
Expand Down Expand Up @@ -56,10 +55,10 @@ export const LoginForm = (props: LoginFormProps) => {
})

switch (error.name) {
case AuthenticationError.name: {
case "AuthenticationError": {
return { [FORM_ERROR]: "Sorry, those credentials are invalid." }
}
case UnconfirmedEmailError.name: {
case "UnconfirmedEmailError": {
return { [FORM_ERROR]: "Please confirm your email first." }
}
default: {
Expand Down
3 changes: 1 addition & 2 deletions app/auth/components/SignupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { SignupInput, SignupInputType } from "app/auth/validations"
import { Card } from "app/components/Card"
import { StyledLink } from "app/components/StyledLink"
import { Logo } from "app/components/Logo"
import { EmailUsedError } from "app/errors/emailUsed"
import { AuthHeading } from "./AuthHeading"
import { AuthWrapper } from "./AuthWrapper"
import { AuthSubheading } from "./AuthSubheading"
Expand Down Expand Up @@ -58,7 +57,7 @@ export const SignupForm = (props: SignupFormProps) => {
})

switch (error.name) {
case EmailUsedError.name: {
case "EmailUsedError": {
return { [FORM_ERROR]: `The email ${values.email} is already being used.` }
}
default: {
Expand Down
4 changes: 2 additions & 2 deletions app/auth/pages/confirm-email/[token].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react"
import { AuthorizationError, BlitzPage, GetServerSideProps, useParam, useRouter } from "blitz"
import { BlitzPage, GetServerSideProps, useParam, useRouter } from "blitz"
import Layout from "app/layouts/Layout"
import { AuthWrapper } from "app/auth/components/AuthWrapper"
import { Logo } from "app/components/Logo"
Expand All @@ -24,7 +24,7 @@ const ConfirmEmail: BlitzPage = () => {

router.push("/")
} catch (e) {
if (e.name === AuthorizationError.name) {
if (e.name === "AuthorizationError") {
setUnauthorized(true)
}
}
Expand Down

0 comments on commit 544a4f8

Please sign in to comment.